栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

什么是Angular ui路由器生命周期?(用于调试静默错误)

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

什么是Angular ui路由器生命周期?(用于调试静默错误)

经过一些试验,我弄清楚了如何充分了解生命周期,以调试我的应用程序并了解正在发生的事情。使用所有事件(包括onEnter,onExit,stateChangeSuccess和此处的
viewContentLoaded),可以使我对事件的发生情况有一个体面的了解,这种方式对代码的灵活性和针对性比书面生命周期更加灵活和具体。在应用程序模块的“运行”功能中,我放置了:

如果我第一次使用Angular和UI-router时就开始使用它,那么这段代码将节省我很多时间和混乱。UI路由器需要“调试”模式,默认情况下启用此功能。

$rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){  console.log('$stateChangeStart to '+toState.name+'- fired when the transition begins. toState,toParams : n',toState, toParams);});$rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams, error){  console.log('$stateChangeError - fired when an error occurs during transition.');  console.log(arguments);});$rootScope.$on('$stateChangeSuccess',function(event, toState, toParams, fromState, fromParams){  console.log('$stateChangeSuccess to '+toState.name+'- fired once the state transition is complete.');});$rootScope.$on('$viewContentLoading',function(event, viewConfig){   console.log('$viewContentLoading - view begins loading - dom not rendered',viewConfig);});$rootScope.$on('$stateNotFound',function(event, unfoundState, fromState, fromParams){  console.log('$stateNotFound '+unfoundState.to+'  - fired when a state cannot be found by its name.');  console.log(unfoundState, fromState, fromParams);});


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/484438.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号