2

I am new to angularjs. I am trying to learn $watch property . Here is my plunker.

rootScope.$watch property is executing on page load only and not on text change event. But it works properly with $scope.$watch.

Taylan Aydinli
  • 4,247
  • 15
  • 38
  • 32
Sanjay Salunkhe
  • 2,407
  • 5
  • 26
  • 49

1 Answers1

11

It will work if you turn it to Object , like:

  $rootScope.name = { value:'World'};

And bind it like:

  <input type="text" ng-model="name.value"></input>

Working: http://plnkr.co/edit/n4QnivBiRvFMAM91UmIT?p=preview

Here you have a great explanation: What are the nuances of scope prototypal / prototypical inheritance in AngularJS?

Community
  • 1
  • 1
Ivan Chernykh
  • 40,230
  • 12
  • 130
  • 145