微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – AngularJs – ng-options在ajax调用后没有绑定

我尝试在ajax调用后更改所选的ng-options索引,但不会更改.
//Html Section...

<select id="fooId" ng-model ="foo.formula"
   ng-options="formulas as name for (formulas,name) in the_formula"></select>

//End Html Section...


//js file...

//get list of formula from server...
TheSource.Get.then(function(response){
    $scope.the_formula = response.the_formula;
});


//do something awesome,then..
//binding data from server...

TheData.Get.then(function(response){
    //binding the data to view...
    //all of the element is binding,except the ng-options part..
    $scope.foo = response; 

    //not working..
    //$scope.formula = response.formulaId //it is return integer ID like (1,2,3,etc..)
});

// End js file...

这是My API发送的数据.

{ 
   "the_formula":{
     "123":"formula1","124":"formula2"
   }
}

怎么了?如何自动更改ng-options中的选择?

解决方法

@reptildarat

你好,

当我使用select和ng-option时,我也遇到了同样的情况.

原文地址:https://www.jb51.cc/ajax/159273.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐