angular.js - angularjs public methods
我想大声告诉你
我想大声告诉你 2017-05-15 17:12:37
0
3
607

The question is this:

    在项目所有的路由页面需要请求后台的一个唯一ID值,然后与前端存储在session的值作比较,不相同则跳转到指定页面,相同则不作处理。
    需要在每个路由页面提取session的值来比较,这个是应该直接写一个service然后注入到controller还是需要其他方法来做?
    
我想大声告诉你
我想大声告诉你

reply all(3)
漂亮男人

It is possible to write a service and inject it into the controller.

But my method is to do it in angular.module.run

淡淡烟草味

The author can determine the routing in the root controller and then set the sub-rules:

$rootScope.$on('$stateChangeSuccess', function(){//Todo sth});

If the poster doesn’t like this method, you can also inject $httpProvider into the config and add $httpProvider.interceptors.push('authInterceptor') and an authInterceptor service,

滿天的星座

You can also do verification processing in the parent controller

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template