dongqiang2024 2017-09-19 13:29
浏览 184


I know that the title is a bit confusing but I've done my best to describe it in a sentence. I want to use angular ng-change in select fields built with CodeIgniter. These selects are generated from an array. Everything is OK except these selects automatically select the same value for all select fields when I change one of them.

<?php $i=1; foreach ($data as $d) : ?>
Username: <input type="text" value="<?php echo $d->username ?>" /><br/>
  <select ng-model="formData[<?php echo $i ?>].id" ng-change="updateUser()">
    <option value="1">Nina</option>
    <option value="2">Naila</option>
    <option value="3">Noni</option>
<?php $i++; endforeach; ?>

So when I change the select by choosing Nina in first select field, for example, then all select fields automatically selects option Nina.

UPDATE: In controller:

.controller('userCtrl', function($scope,$http){

   $scope.formData = {};
   $scope.updateUser = function(){
      for (var i=1; i < $scope.formData.length; i++){

With this, I got nothing when I examine it in console.

I tried to add attribute name=id[] on select but still no luck. Please help. Thanks.

  • 写回答

2条回答 默认 最新


      相关推荐 更多相似问题


      • ¥15 如何关闭soui dummy wdn 进程
      • ¥20 含有jar文件的文件夹用tar -zcvf 命令压缩后要怎么还原回去?
      • ¥15 天宝TBC软件出现报错怎么解决
      • ¥15 micropython 从1开始切片报错
      • ¥15 请问该怎么做才能将文字说明和二维码一起作为png图片一起下载
      • ¥15 r语言 混频数据回归 midas_r
      • ¥15 人脸识recogizer.predict返回值id报错,KeyError,详情如下
      • ¥15 geowebcache部署失败
      • ¥20 关于adaboost+haar特征实现人脸检测过程的一些细节问题
      • ¥15 csv文件增加一列 为csv文件的名字