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

$scope.$watch #58

Closed
daniele-zurico opened this issue Nov 2, 2015 · 2 comments
Closed

$scope.$watch #58

daniele-zurico opened this issue Nov 2, 2015 · 2 comments

Comments

@daniele-zurico
Copy link

Hello all guys,
I don't know if that problem was already solved (i've take a look on the previous bugs but there is nothing on that).

So I've created a component like that:

<my-component [(data)]="serverData"></my-component>

serverData is updated from clickEvent or after n minutes and inside my component I've:

$scope.$watch('je.data', (n) => { 
 //perform action
});

Obviously it's a failure point for angular 2.0. How I can avoid that?

tnx

@david-gang
Copy link
Contributor

What is exactly the problem?

@MikeRyanDev
Copy link
Member

One of the features we have planned is to support opt-in lifecycle events just like Angular 2. Preferably, we'd like this to be a launch feature for ng-forward.

In your example, lifecycle events would work like this:

@Component({ selector: 'my-component' })
class MyComponent{
  onChange(propertyName: string, changes: propertyChange){
    console.log(`Property: ${propertyName}, oldValue: ${changes.oldValue}, newValue: ${changes.newValue}`);
  }
}

Until this lands, you'll unfortunately need to continue injecting $scope and manually creating watchers.

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

No branches or pull requests

3 participants