对不起伙计们,这是我在stackoverflow中的第一个问题,所以我编辑了这个问题以便更清楚。
我有一个角度应用程序,我希望用户可以在没有启用 html5mode的情况下按照“ http://myapp.com/username ”而不是“ http://myapp.com/#/user/username ”检查他们的个人资料. 我怎样才能做到这一点?
提前致谢。
对不起伙计们,这是我在stackoverflow中的第一个问题,所以我编辑了这个问题以便更清楚。
我有一个角度应用程序,我希望用户可以在没有启用 html5mode的情况下按照“ http://myapp.com/username ”而不是“ http://myapp.com/#/user/username ”检查他们的个人资料. 我怎样才能做到这一点?
提前致谢。
您可以尝试在 .run 角度模块中调用您的 ajax 调用吗?
参考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
> }])