angular的@uirouter的lazyload功能,在使用onBefore hook时,如果不进行一定设置是监听不到lazyload的hook的。原来是因为lazy loade hook的优先级是0,要设置此hook需要在onBefore中设置priority: 1

在uirouter的github的一个issue中给出了解释:传送门

You should be able to implement this with these existing primitives:
* lazyLoad property on a state
* An onBefore Transition Hook when entering a lazyload state
* A Transition promise
javascript
const criteria = { entering: (state) => !!state.lazyLoad };
const options = { priority: 1 };
const hook = trans => {
console.log('Lazy load starting...');
const done = () => console.log('Lazy load complete!');
trans.promise.then(done, done)
};
uiRouter.transitionService.onBefore(criteria, hook, options);

Here’s an example: https://stackblitz.com/edit/ui-router-angular-ysa7jk?file=app%2Fapp.module.ts

Note: priority: 1 is necessary because the lazy load hook itself is a priority 0 onBefore hook.

分类: angularjs

5 条评论

lipitor medication · 2021年3月17日 上午5:55

citalopram price citalopram 10mg pricescitalopram prices citalopram without prescription

levaquin 250mg without a prescription · 2021年3月25日 上午4:17

prochlorperazine generic prochlorperazine 5 mg priceprochlorperazine tablets prochlorperazine prices

keflex 500 mg pills · 2021年4月17日 上午12:04

where to buy acetazolamide cheap acetazolamide 250 mgacetazolamide purchase acetazolamide coupon

cost of lopid · 2021年5月8日 上午3:29

oxybutynin without a doctor prescription where to buy oxybutynin 5mgoxybutynin purchase oxybutynin pills

Galempolype · 2021年5月28日 下午6:13

Mojoheadz Records remains at the forefront of mind-expanding soundz. Even today, the imprint embraces the obscure and abstract just as passionately as it did in its formative years, never losing sight of its creative vision as it’s grown and flourished year upon year.Check review… https://open.spotify.com/album/4gW8T09WWnncEa66Wzgyse

发表评论

邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据