How to $watch changes on models created by ng-repeat?

后端 未结 6 1986
感动是毒
感动是毒 2020-12-08 00:53

Consider this Plnkr for example. I don\'t know how many members of fooCollection will be created beforehand. So I don\'t know how many bar models a

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 01:07

    Try to do this

     
    Tell me your ame:
    Hello, my name is {{foo.bar}}

    There is the code in Directive/Controller

     $scope.selectedfoo = {};
     $scope.select = (foo) => {
        $scope.selectedfoo = foo;
     }
    
     $scope.$watch('selectedfoo ', (newVal, oldVal) => {
      if (newVal) {
    
      }
     },true)
    

提交回复
热议问题