AngularJS路由之ui-router(三)
来源:互联网 发布:女娲 知乎 编辑:程序博客网 时间:2024/06/06 15:39
一、为ui-router添加进度条
在使用动态控制器或者ajax,添加数据的时候需要进度条提示,
我们可以使用路由状态的事件添加全局进度条提示
$stateChangeStart: 当状态开始改变时触发
$stateChangeSuccess: 当状态改变结束时触发
二、实例1,创建一个进度条指令
// Route State Load Spinner(used on page or content load)MetronicApp.directive('ngSpinnerBar', ['$rootScope', '$state', function($rootScope, $state) { return { link: function(scope, element, attrs) { // by defult hide the spinner bar element.addClass('hide'); // hide spinner bar by default // display the spinner bar whenever the route changes(the content part started loading) $rootScope.$on('$stateChangeStart', function() { element.removeClass('hide'); // show spinner bar }); // hide the spinner bar on rounte change success(after the content loaded) $rootScope.$on('$stateChangeSuccess', function() { element.addClass('hide'); // hide spinner bar $('body').removeClass('page-on-load'); // remove page loading indicator Layout.setAngularJsSidebarMenuActiveLink('match', null, $state); // activate selected link in the sidebar menu // auto scorll to page top setTimeout(function () { App.scrollTop(); // scroll to the top on content load }, $rootScope.settings.layout.pageAutoScrollOnLoad); }); // handle errors $rootScope.$on('$stateNotFound', function() { element.addClass('hide'); // hide spinner bar }); // handle errors $rootScope.$on('$stateChangeError', function() { element.addClass('hide'); // hide spinner bar }); } }; }])
更多:
AngularJS路由之ui-router(二)
AngularJS路由之ui-router(一)
0 0
- AngularJS路由之ui-router(三)
- AngularJS路由之ui-router(三)大小写处理
- 初学AngularJs路由(三):Ui-router
- AngularJS路由之ui-router(一)
- AngularJS路由之ui-router(二)
- angularJs模块ui-router之路由控制
- AngularJS ui-router (嵌套路由)
- AngularJS ui-router (嵌套路由)
- AngularJS ui-router (嵌套路由)
- AngularJS ui-router (嵌套路由)
- AngularJS ui-router (嵌套路由)
- AngularJS ui-router (嵌套路由)
- AngularJS ui-router (嵌套路由)
- AngularJS ui-router (嵌套路由)
- AngularJS ui-router (嵌套路由)
- AngularJS ui-router (嵌套路由)
- AngularJS ui-router (嵌套路由)
- AngularJS ui-router (嵌套路由)
- intent传值
- INVALID_USER_SCODE BUG 解决方案
- Android手机的休眠状态
- android中setBackgroundColor()中不能设置背景颜色的问题
- 编写一个程序,读取键盘输入,直到遇到@符号为止,并回显输入(数字除外),同时将大写字符转换为小写,将小写字符转换为大写(别忘了cctype函数系列)
- AngularJS路由之ui-router(三)
- 误删文件的恢复-extundelete
- Ship wakes: Kelvin or Mach angle?
- 最大公约数与最小公倍数
- Zurmo(九)----货币机制
- Android广播之发送广播的源码分析
- Ship Kelvin Wake
- 2016-12-18日股市复盘
- 《React-Native系列》37、 ReactNative百度地图开源组件使用