angular2 - infinite loop when i call method from a Angular 2 class inside template

You should not use methods in your template, because each time Angular runs change detection, the method will be called, which can happen often. So actually this is not an infinite loop, the method just gets called on each change detection.

To avoid this, you need to change your code to handle the logic of methods in your component, and use variables in your template instead.


i finally found the sollution , it's to change Detection Strategy to OnPush for more information visite this link Change Detection Strategy: OnPush

Tags:

Angular