Answer the question
In order to leave comments, you need to log in
How to listen to model in angular using controller as syntax?
Don't know how to listen to controller property via $scope
codepen.io/Tek/pen/fGuwl - controller as syntax
http://codepen.io/Tek/pen/zqCpF /?editors=111 - $scope
Answer the question
In order to leave comments, you need to log in
in connection with the study of angular, the same question arose, I myself will answer it
"as syntax" - in fact, just sugar for such an option
<div ng-controller="MyCtrl as my"> </div>
function MyCtrl($scope){
$scope.my = this;
this.val = "";
}
$scope.$watch('my.val', function(newVal){
console.log(newVal);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question