AngularJS:从引导的UI手风琴访问范围手风琴、范围、AngularJS、UI

由网友(余生不孤独)分享简介:我试图$观看的UI,引导手风琴,在模型的变化。在视图中结合的作品,但是当模型发​​生变化,$手表不火。 I'm trying to $watch for a change on a model within a ui-bootstrap accordion. Binding works within the view...

我试图$观看的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);
  })
}

Plunker

阅读全文

相关推荐

最新文章