ng-model在IE中没有更新

时间:2016-07-25 07:45:03

标签: angularjs angular-ngmodel

下面的代码设置了ng-model JUST ONCE,而在CHROME和FF中它工作正常。

<form>
        <div ng-repeat="ques in $.vm.records track by $index">

            <div class="input-group">
                <select ng-model="ques.choiceid">
                    <option value=""></option>
                    <option value="{{choice.id}}" ng-repeat="choice in ques.choices track by $index" >{{ choice.text }}</option>
                </select>               
            </div>
        </div>
    </form>

UPDATE 我使用的是角度版本1.4.7,浏览器版本是IE11

1 个答案:

答案 0 :(得分:1)

尝试使用ng-options选择角度选择下拉列表,如角度文档中所示。 以下代码适用于IE。

<!DOCTYPE html>
  <html>
   <head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">   </script>
   </head>
   <body>

    <div ng-app="myApp" ng-controller="myCtrl">

     <select ng-options="item as item.label for item in items track by item.id" ng-model="selected"></select>

     <div class="">
       Selected id : {{selected.id}} and value : {{selected.label}}
     </div>
   </div>

  <script>
    var app = angular.module('myApp', []);
    app.controller('myCtrl', function($scope) {
    $scope.items = [{
                     id: 1,
                     label: 'aLabel',
                     subItem: { name: 'aSubItem' }
                   }, {
                     id: 2,
                     label: 'bLabel',
                     subItem: { name: 'bSubItem' }
                  }];
    });
  </script>

 </body>
</html>