app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($routeProvider, $httpProvider, $locationProvider) { var rootPath = '/assets/wechat/' //$locationProvider.html5Mode(true); $routeProvider .when('/activites', { templateUrl: rootPath + 'activities.html', controller: 'ActivityController' }) .when('/issues/:id', { templateUrl: rootPath + 'issue_detail.html', controller: 'IssueController' }) .when('/project_discussion/:id', { templateUrl: rootPath + 'project_discussion.html', controller: 'DiscussionController' }) .when('/homework/:id', { templateUrl: rootPath + 'homework_detail.html', controller: 'HomeworkController' }) .when('/course_notice/:id', { templateUrl: rootPath + 'course_notice.html', controller: 'CourseNoticeController' }) .when('/course_discussion/:id', { templateUrl: rootPath + 'course_discussion.html', controller: 'DiscussionController' }) .when('/journal_for_message/:id', { templateUrl: rootPath + 'jour_message_detail.html', controller: 'JournalsController' }) .when('/blog_comment/:id', { templateUrl: rootPath + 'blog_detail.html', controller: 'BlogController' }) .when('/add_class', { templateUrl: rootPath + 'add_class.html', controller: 'AddClassController' }) .otherwise({ redirectTo: '/activites' }); //监听异步请求,实现加载中显隐标记 $httpProvider.interceptors.push(function ($q, $rootScope) { if ($rootScope.activeCalls == undefined) { $rootScope.activeCalls = 0; } return { request: function (config) { $rootScope.activeCalls += 1; return config; }, requestError: function (rejection) { $rootScope.activeCalls -= 1; return rejection; }, response: function (response) { $rootScope.activeCalls -= 1; return response; }, responseError: function (rejection) { $rootScope.activeCalls -= 1; return rejection; } }; }); }]);