简体   繁体   English

在角负载之前执行脚本

[英]Execute Script before angular load

Sorry Guys this is my first question in stackoverflow, so I edited the question in order to be more clear. 抱歉,这是我在stackoverflow中的第一个问题,因此为了更清楚地编辑了问题。

I have an angular app and I would like that the users could check their profile as following " http://myapp.com/username " instead of " http://myapp.com/#/user/username " without the html5mode enable. 我有一个角度应用程序,我想的是,用户可以查看他们的个人资料如下“ http://myapp.com/username ”而不是“ http://myapp.com/#/user/username ”没有html5mode启用。 How can I achieve this? 我该如何实现?

Thanks in advance. 提前致谢。

can you try calling your ajax call in .run angular module. 您可以尝试在.run angular模块中调用ajax调用吗?

go with reference http://jsfiddle.net/lovedota/qpwwm8bn/ 请参考http://jsfiddle.net/lovedota/qpwwm8bn/

> angular.module('app', ['ngRoute', 'app.auth']) 
> .factory('AuthService', ['$q', function ($q) {} 
> .config(['$routeProvider', function($routeProvider) {
>             $routeProvider.             
>               otherwise({
>                 redirectTo: '/'
>               });
>       }])
> 
> .run(['$http', function($http){
>         // make your ajax call or you can inject another module which bring user id
>     }])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM