我在HTTP请求完成时尝试重定向到我的应用上带参数的另一个页面:
app.controller("startSess", function($scope, $http, $window, $state){
var self = this;
$scope.startNewSession = function(){
self.newSessionData = {"nick": thisScope.nick, "password": thisScope.password}; //The password is not sensitive information
$http({
method: "POST",
url: "api/newsession.php",
data: $.param({"data": self.newSessionData}),
headers: {"Content-Type": "application/x-www-form-urlencoded"}
}).success(function(reply){
if(reply.status == "complete"){
$state.go('home'); //This is where the error occurs.
}
});
};
});
执行此代码后,我得到:
> Object {} app.js:37 TypeError: undefined is not a function
> at http://site.co.uk/angular/oneword/scripts/app.js:56:11
> at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js:72:199
> at L (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js:100:187)
> at L (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js:100:187)
> at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js:101:350
> at k.$eval (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js:112:68)
> at k.$digest (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js:109:147)
> at k.$apply (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js:112:398)
> at h (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js:72:454)
> at v (http://ajax
.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js:77:463) an
答案 0 :(得分:0)
在dotjem路由中显示:$state.goto('home', {/* OPTIONAL: Params here */});
和 不 :$state.go('blah', {/* OPTIONAL: Params here */})