How to properly use the same AngularJS 1.5 component multiple times in a view?

后端 未结 2 1471
情书的邮戳
情书的邮戳 2021-01-26 09:46

I\'m creating a set of widgets with AngularJS 1.5\'s new components. The problem is, when using the same widget multiple times, they somehow share their controller or scope. I t

2条回答
  •  花落未央
    2021-01-26 10:38

    Looks like you have a global variable called $widget here, try this:

    var $widget = this;
    

    instead of

    $widget = this;
    

    It creates a mess since the $widget variable holds a reference to the controller that has been recently initialized, in this case to the controller of the third component.

提交回复
热议问题