Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question in Integrating Expressions to Scopes #366

Open
yankwan opened this issue Dec 10, 2017 · 0 comments
Open

Question in Integrating Expressions to Scopes #366

yankwan opened this issue Dec 10, 2017 · 0 comments

Comments

@yankwan
Copy link

yankwan commented Dec 10, 2017

In page 349, in the case 'accepts expressions for watch functions':

it('accepts expressions for watch functions', function() {
  var theValue;
  scope.aValue = 42;
  scope.$watch('aValue', function(newValue, oldValue, scope) {
    theValue = newValue;
  });
  scope.$digest();
  expect(theValue).toBe(42);
});

scope.js

Scope.prototype.$watch = function(watchFn, listenerFn, valueEq) {  
     var self = this;    
     var watcher = {
           watchFn: parse(watchFn),
            listenerFn: listenerFn || function() { },   
            last: initWatchVal,   
            valueEq: !!valueEq  	
       };
       ...
}

I am confused about that how watchFn : parse(watchFn) relation to the Scope. When parse(watchFn) return the function functon() {return aValue}, witch the variable aValueis not relation to the scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant