AngularJS:从引导的UI手风琴访问范围 [英] AngularJS: access scope from bootstrap-ui accordion
本文介绍了AngularJS:从引导的UI手风琴访问范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图$观看的UI,引导手风琴,在模型的变化。在视图中结合的作品,但是当模型发生变化,$手表不火。
I'm trying to $watch for a change on a model within a ui-bootstrap accordion. Binding works within the view, but when the model changes, the $watch doesn't fire.
http://plnkr.co/edit/DcoGT2?p=$p$ PVIEW
我如何得到$ scope.myModel值控制器?
How do I get the value of $scope.myModel in the controller?
推荐答案
使用的对象,而不是原始的:
Use an object rather than a primitive:
<div ng-controller="AccordionDemoCtrl">
<accordion>
<accordion-group heading="Static Header">
<input ng-model="model.myModel"> {{ model.myModel }}
</accordion-group>
</accordion>
</div>
angular.module('plunker', ['ui.bootstrap']);
function AccordionDemoCtrl($scope) {
$scope.model = {myModel: ''};
$scope.$watch('model.myModel',function(){
console.log($scope.model.myModel);
})
}
这篇关于AngularJS:从引导的UI手风琴访问范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文