Skip to content

Watch and this #176

@zgababa

Description

@zgababa

Hi,

I think there is a mistake in controllerAs with vm -> [Style Y032] section, I can't reproduce the example.

HTML

<div class="container" ng-controller="TestController as d">
    <input type="text" ng-model="d.title">
</div>

From the styleguide

var vm = this;
this.vm = "Hi";
$scope.$watch('vm.title', function(current, original) {
    $log.info('vm.title was %s', original); 
    $log.info('vm.title is now %s', current); // Nothing happen, when I typing
});

But that works (from the tuto controllerAs http://toddmotto.com/digging-into-angulars-controller-as-syntax/)

 var vm = this;
 vm.title = "";

  $scope.$watch(function () {
      return vm.title;
    }, function (current, original) {
      $log.info('vm.title was %s', original);
      $log.info('vm.title is now %s', current);
  });

Am I wrong or not ?

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions