1
我有一个方法是使用evalAsync和我想设置一个最大等待时间来解决承诺,如果等待时间达到最大超时那么承诺将是解决并返回空。有关如何完成此任何想法?
很难找到解决方案,因为每个搜索条件evalasync和超时,“污染”结果$超时。
if (angular.isFunction(this.search)) {
this.cancellation = this.$q.defer<void>();
this.$scope.$evalAsync(() => {
const searchArgs= {
value: this.value,
cancellation: this.cancellation.promise
};
const result = this.search(args);
});
}
};
由于
请张贴您的代码。 – Karim
我建议使用'setTimeout'(不是'$ timeout'来防止一个新的摘要循环,并且在这个$ scope。$ evalAsync'之外拒绝'this._cancellation', –
@AlonEitan你能给出一个这个建议的例子吗? – Javiere