6 HAZİRAN 2014, Cuma
Angularjs: 'sözdizimi denetleyicisi' ve $İzle
Kullanırken mülkiyet değişikliği abone olmak için nasıl "sözdizimi"? denetleyicisi
controller('TestCtrl', function ($scope) {
this.name = 'Max';
this.changeName = function () {
this.name = new Date();
}
// not working
$scope.$watch("name",function(value){
console.log(value)
});
});
<div ng-controller="TestCtrl as test">
<input type="text" ng-model="test.name" />
<a ng-click="test.changeName()" href="#">Change Name</a>
</div>
CEVAP
18 AĞUSTOS 2014, PAZARTESİ
Ben genellikle bunu yapmak için:
controller('TestCtrl', function ($scope) {
var self = this;
this.name = 'Max';
this.changeName = function () {
this.name = new Date();
}
$scope.$watch(function () {
return self.name;
},function(value){
console.log(value)
});
});
Bunu Paylaş:
AngularJs "denetleyicisi" sö...
Mücadele iki kez denetleyicisi yürütme...
Yükleme AngularJS denetleyicisi dinami...
Diğer kumanda dan Direktif denetleyici...
AngularJS : izle Net $...