(click) broken inside *ngFor on elements of type array if coming from a function

前端 未结 2 581
臣服心动
臣服心动 2021-01-21 10:19

in plnkr I\'ve reproduced a strange edge case. It probably depends on pixijs or perhaps on webgl as it happens when using pixijs.

Notice how you can click on all the

2条回答
  •  庸人自扰
    2021-01-21 10:28

    The problem is caused by

      ns() {
        return [[2,4],'ciao',4,true];
      }
    

    and

    With every event Angular invokes change detection and each time it checks whether the previously returned value from ns() is the same as the current one it turns out to be different every time, because each call to ns() returns a new array. Angular expects the model to stabilize.

    Angular doesn't compare properties or the contents of objects and arrays, it only does identity checks and ns() for every call returns a new and thus different array instance.

    Instead it should be

      var arr = [[2,4],'ciao',4,true]; 
      ns() {
        return this.arr;
      }
    

提交回复
热议问题