博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AngularJS路由之ui-router(三)
阅读量:4287 次
发布时间:2019-05-27

本文共 1860 字,大约阅读时间需要 6 分钟。

一、为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                });            }        };    }])
更多:

转载地址:http://kjogi.baihongyu.com/

你可能感兴趣的文章
mysql-5.0.27-win32安装
查看>>
jquery之选择器简介
查看>>
html中绝对路径和相对路径
查看>>
DOM对象与jquery对象的差异
查看>>
使用jquery隐藏和移动dom
查看>>
JSP中使用路径问题
查看>>
Could not parse configuration: /hibernate.cfg.xml
查看>>
使用Httpclient4.4+Jsoup登录3G版人人网
查看>>
HttpClient模拟手机人人网登陆(一)---抓包
查看>>
在FireFox/IE浏览器中关闭缓存
查看>>
IE与火狐关于获取按键不兼容处理
查看>>
【跟我学Apache Commons】【一】综述
查看>>
【跟我学Apache Commons】【二】Lang&Math
查看>>
Eclipse文本高亮
查看>>
Junit4学习教程
查看>>
[Java]各种日志详细总结
查看>>
Maven-入门篇
查看>>
Jackson介绍(1)-jackson2.x与Jackson1.9的比较
查看>>
Nginx反向代理Tomcat
查看>>
java io-1基本概念
查看>>