【发布时间】:2014-03-07 05:33:02
【问题描述】:
我正在尝试在 module.config() 对象中设置一些基本的应用程序数据,并且我只在用户使用附加到特定入口点的唯一键点击应用程序时这样做,否则我的状态将通过不同的方式解析回复。
我使用$urlRouterProvider.when(),在指定的入口点捕获用户,然后解析promise ($http.get()),然后返回状态。但似乎无法使其工作。数据本身确实返回,但函数没有返回路径,我不知道为什么。
$urlRouterProvider.when('/hi/:userkey',function($match,$rootScope, $http){
$http.get('http://api.com/login/'+$match.userkey)
.success(function(result){
$rootScope.data = result;
return '/home';
})
});
我也试过在.then()中设置返回值:
.then(function(){
return '/home';
})
我没有收到任何错误,但没有处理返回值。
【问题讨论】:
标签: javascript angularjs promise angular-ui-router