Does ng-init watch over change on instantiated property like ng-model does?
Apparently not, so I set a watch as shown below:
app.js
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.$watch('myProp1', function(newVal, oldVal){
$scope.myProp1 = newVal
})
});
html
<body ng-controller="MainCtrl">
<input ng-init='myProp="my property"'>{{myProp}}</br>
<input ng-init='myProp1="my 1 property"'>{{myProp1}}</br>
<input ng-init='myProp11="my 11 property"' ng-model='myProp11'>{{myProp11}}
Here is plnkr
- Does ng-init watch over change on instantiated property like ng-model does?
- How do I watch the changes in the property instantiated by ng-init?
- What's wrong with the $watch function above?