Angular .done() 动画回调被调用了两次吗?(棱角2)



我尝试了几个看似常见的修复程序,都显示在 plnkr 中:

  1. 在"我的按钮"上指定"type="button"">
  2. 将 Angular 从开发模式中移除

如果你点击"下一步"按钮,然后打开Javascript控制台,你会注意到我的'done(('函数每次点击都会运行两次:

http://embed.plnkr.co/HKlKWfV6JjWRxZiOnAJt/

我也尝试传入"$event"并使用 preventDefault(( 和 stopPropagation((,但没有运气。

谢谢。

我对代码进行了一些调整以返回预期的行为。例如移动到array索引。

done(){
console.log('Running done(). index: ' + this.index);
 //I removed the this.index++ here;
 if(this.index>2) this.index=0;
 this.name=this.strs[this.index];
 this.nameState2='active';
}
next(){
 this.index++; // <=== I removed the comment here.
 //if(this.index>2) this.index=0;
 //this.name=this.strs[this.index];
 this.nameState2='inactive';
}

我移动了next()函数上的index++。但在控制台上,它仍然调用done()两次。但是名称/索引的行为正在正常工作。

最新更新