SORU
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ş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Best Quality Cartoons

    Best Quality

    10 ŞUBAT 2014
  • jkimisyellow

    jkimisyellow

    6 Mayıs 2009
  • KoreanFrogMania님의 채널

    KoreanFrogMa

    18 Aralık 2011