Angularjs: 'controller as syntax' and $watch

前端 未结 10 1589
抹茶落季
抹茶落季 2020-11-28 18:52

How to subscribe on property change when using controller as syntax?

controller(\'TestCtrl\', function ($         


        
10条回答
  •  清歌不尽
    2020-11-28 19:38

    AngularJs 1.5 supports the default $ctrl for the ControllerAs structure.

    $scope.$watch("$ctrl.name", (value) => {
        console.log(value)
    });
    

提交回复
热议问题