Bonjour,
Voila je rencontre un petit problème avec mon code.
Je développe un projet avec angularjs et cakephp depuis plusieurs jours mais je coince à un problème.
lorsque de la création de mon formulaire je fais certains traitements avec angularjs sans problème . Voici le form de creation
<div class="row" ng-controller="campagnesCtrl">
<div class="col-lg-2"></div>
<div class="col-md-8 col-lg-8">
<?= $this->Html->link("<span class='fa fa-bullhorn pr5'></span>" . __('Mes campagnes'),['controller' =>'Contacts','action' => 'newCampagne','plugin'=>'Admin'],['class' =>'btn btn-system','escape'=>false]);?>
<?= $this->Html->link("<span class='fa fa-paperclip pr5'></span>Mes contacts",['controller' =>'Contacts','action' => 'singleContact','plugin'=>'Admin'],['class' =>'btn btn-dark','escape'=>false]);?>
<br><br>
<div class="panel panel-primary">
<div class="panel-heading">
<span class="fa fa-bullhorn"></span> <?= __('Nouveau passage');?>
</div>
<div class="panel-body">
<?php echo $this->Form->create($push,['class'=>'form-horizontal','role' =>'form']); ?>
<div class="form-group">
<label for="inputStandard" class="col-lg-3 control-label"><?= __('Identifiant expéditeur');?>
</label>
<div class="col-lg-8">
<?= $this->Form->input('id_expediteur',['type' => 'text','class' => 'form-control','placeholder'=>__('Identifiant'),'div'=>false,'ng-model'=>'idexpediteur','label'=>false,'ng-change'=>"SearchexistID(idexpediteur)"]);?>
</div>
</div>
<div class="form-group">
<label for="inputStandard" class="col-lg-3 control-label"><?= __('Contact');?>
</label>
<div class="col-lg-6">
<?= $this->Form->input('categorie_contact_id',['type' => 'select','class' => 'form-control','div'=>false,'require'=>true,'id'=>'multiselect2','label'=>false,'options'=>$listegroupes,'multiple'=>true,"ng-model"=>"contact","ng-change"=>"ShowContact(contact,'$crf')"]);?>
</div><span ng-bind="total" class="col-lg-3"></span>Contact
</div>
<div class="form-group">
<label for="inputStandard" class="col-lg-3 control-label"><?= __('Type message');?>
</label>
<div class="col-lg-8">
<?= $this->Form->input('type_sms',['type' => 'select','class' => 'form-control','empty'=>__('Type message'),'div'=>false,'label'=>false,'options'=>['flash'=>'Message flash','single'=>'message single'],'required'=>true]);?>
</div>
</div>
<div class="form-group">
<label for="inputStandard" class="col-lg-3 control-label"><?= __('Encodage');?>
</label>
<div class="col-lg-8">
<?= $this->Form->input('type_codage',['type' => 'select','class' => 'form-control','empty'=>__('Encodage'),'div'=>false,'label'=>false,'options'=>['text'=>'Text/Plain','iso'=>'ISO'],'required'=>true]);?>
</div>
</div>
<div class="form-group">
<label for="inputStandard" class="col-lg-3 control-label"><?= __('Message');?>
</label>
<div class="col-lg-8">
<?= $this->Form->input('messages',['type' => 'textarea','class' => 'form-control','placeholder' =>__('Message'),'div'=>false,'label'=>false,'required'=>true,'maxlength'=>160,"ng-model"=>"textcontent","ng-change"=>"countCharactere(textcontent)"]);?>
<span class="input-footer">
<strong>NB:</strong>
<?=__('Il vous reste ')?><span ng-bind="nbtotal"></span><?=__(' caractères sur 160 caractères au total')?>
</span>
</div>
</div>
<div class="form-group">
<label for="maskedMultiple" class="col-lg-3 control-label"><?= __('Date lancement');?>
</label>
<div class="col-lg-8 datetime" id="maskedMultiple">
<?= $this->Form->input('date_debut_push',['type' => 'text','class' => 'form-control ','placeholder'=>__('Date lancement'),'label'=>false,'require'=>true,"autocomplete"=>"off"]);?>
</div>
</div>
<div class="form-group">
<div class="col-lg-6 col-sm-5 col-md-6 col-xs-5 btnform">
<?php
echo $this->Form->button(' Annuler', array('type'=>'reset','class'=>'btn btn-rounded btn-danger btn-block glyphicon glyphicon-refresh')); ?>
</div>
<div class="col-lg-6 col-sm-5 col-md-6 col-xs-5 btnform">
<?php
echo $this->Form->button('<span class="glyphicon glyphicon-ok"></span> Ajouter', ['type'=>'submit','class'=>' btn btn-rounded btn-primary btn-block '],['escape'=>true]);?>
</div>
</div>
<?php echo $this->Form->end();?>
</div>
</div>
</div>
<div class="col-lg-2"></div>
</div>
et le controlleur angularjs qui va avec:
mainApp.controller('campagnesCtrl',function($scope,$rootScope,$http,$location){
var path = $location.absUrl();
$scope.ShowContact = function(contact,crf){
var link = path.substring(0 ,~path.lastIndexOf( "/" ))+ '../totalContactgroup';
if((typeof contact) !='undefined' && contact.length != 0)
{
$http({
method: 'POST',
headers : {
'X-CSRF-Token': crf
},
dataType : "json",
data : {'groupe':contact},
url : link}
).then(function successCallback(response){
$scope.total = response.data;
});
}
else
{
$scope.total = '';
}
};
$scope.nbtotal = 160;
$scope.countCharactere = function(chr){
$scope.nbtotal = 160 - chr.length;
};
$scope.SearchexistID = function(idexpediteur){
var tabinterdit = ['MINSANTE','PR','CDE'];
if(!$.inArray(idexpediteur,tabinterdit))
{
alert("Cet identifiant est interdit");
$scope.idexpediteur =null;
}
}
});
mais par contre lorsque je veux faire une modification avec le même code soit:
<div class="row" ng-controller="campagnesCtrl" ng-init="data.idexpediteur = rrr">
<div class="col-lg-2"></div>
<div class="col-md-8 col-lg-8">
<?= $this->Html->link("<span class='fa fa-bullhorn pr5'></span>" . __('Mes campagnes'),['controller' =>'Contacts','action' => 'newCampagne','plugin'=>'Admin'],['class' =>'btn btn-system','escape'=>false]);?>
<?= $this->Html->link("<span class='fa fa-paperclip pr5'></span>Mes contacts",['controller' =>'Contacts','action' => 'singleContact','plugin'=>'Admin'],['class' =>'btn btn-dark','escape'=>false]);?>
<br><br>
<div class="panel panel-primary">
<div class="panel-heading">
<span class="fa fa-bullhorn"></span> <?= __('Edit passage');?>
</div>
<div class="panel-body">
<?php echo $this->Form->create($campagne,['class'=>'form-horizontal','role' =>'form','type'=>"post","novalidate"=>true]); ?>
<div class="form-group">
<label for="inputStandard" class="col-lg-3 control-label"><?= __('Identifiant expéditeur');?>
</label>
<div class="col-lg-8">
<?= $this->Form->input('id_expediteur',['type' => 'text','class' => 'form-control','placeholder'=>__('Identifiant'),'div'=>false,'label'=>false,'ng-model'=>'data.idexpediteur','ng-change'=>"SearchexistID(idexpediteur)",'id'=>false,"ng-value"=>"{{ok}}"]);?>
</div>
</div>
<div class="form-group">
<label for="inputStandard" class="col-lg-3 control-label"><?= __('Contact');?>
</label>
<div class="col-lg-6">
<?= $this->Form->input('categorie_contact_id',['type' => 'select','class' => 'form-control','div'=>false,'require'=>true,'id'=>'multiselect2','label'=>false,'options'=>$listegroupes,'multiple'=>true,"ng-model"=>"contact","ng-change"=>"ShowContact(contact,'$crf')"]);?>
</div><span ng-bind="total" class="col-lg-3"></span>Contact
</div>
<div class="form-group">
<label for="inputStandard" class="col-lg-3 control-label"><?= __('Type message');?>
</label>
<div class="col-lg-8">
<?= $this->Form->input('type_sms',['type' => 'select','class' => 'form-control','empty'=>__('Type message'),'div'=>false,'label'=>false,'options'=>['flash'=>'Message flash','single'=>'message single'],'required'=>true]);?>
</div>
</div>
<div class="form-group">
<label for="inputStandard" class="col-lg-3 control-label"><?= __('Encodage');?>
</label>
<div class="col-lg-8">
<?= $this->Form->input('type_codage',['type' => 'select','class' => 'form-control','empty'=>__('Encodage'),'div'=>false,'label'=>false,'options'=>['text'=>'Text/Plain','iso'=>'ISO'],'required'=>true]);?>
</div>
</div>
<div class="form-group">
<label for="inputStandard" class="col-lg-3 control-label"><?= __('Message');?>
</label>
<div class="col-lg-8">
<?= $this->Form->input('messages',['type' => 'textarea','class' => 'form-control','placeholder' =>__('Message'),'div'=>false,'label'=>false,'required'=>true,'maxlength'=>160,"ng-model"=>"textcontent","ng-change"=>"countCharactere(textcontent)"]);?>
<span class="input-footer">
<strong>NB:</strong>
<?=__('Il vous reste ')?><span ng-bind="nbtotal"></span><?=__(' caractères sur 160 caractères au total')?>
</span>
</div>
</div>
<div class="form-group">
<label for="maskedMultiple" class="col-lg-3 control-label"><?= __('Date lancement');?>
</label>
<div class="col-lg-8 datetime" id="maskedMultiple">
<?= $this->Form->input('date_debut_push',['type' => 'text','class' => 'form-control ','placeholder'=>__('Date lancement'),'label'=>false,'require'=>true,"autocomplete"=>"off"]);?>
</div>
</div>
<div class="form-group">
<div class="col-lg-6 col-sm-5 col-md-6 col-xs-5 btnform">
<?php
echo $this->Form->button(' Annuler', array('type'=>'reset','class'=>'btn btn-rounded btn-danger btn-block glyphicon glyphicon-refresh')); ?>
</div>
<div class="col-lg-6 col-sm-5 col-md-6 col-xs-5 btnform">
<?php
echo $this->Form->button('<span class="glyphicon glyphicon-ok"></span> Ajouter', ['type'=>'submit','class'=>' btn btn-rounded btn-primary btn-block '],['escape'=>true]);?>
</div>
</div>
<?php echo $this->Form->end();?>
</div>
</div>
</div>
<div class="col-lg-2"></div>
</div>
et le même code angularjs pour les traitement .
lors de l'édition, mon formulaire d'édition se remplie bien sauf les champs controlé par angujar js (tout les champs contenuant la directive ng-model)
pouvoir remplir tout les champs de mon formulaire même ceux controller par angularjs
lors du chargement de la page je vois bien tout les valeurs des champs de mon formulaire, mais après chargement les champs contenant la directive ng-model sont vide.
la je ne comprends plus quelqu'un à déjà eu ce soucis? SVP