Angularjs $state.go()未定义不是函数
当HTTP请求完成时,我尝试重定向到另一个带有我的应用程序参数的页面:Angularjs $state.go()未定义不是函数,angularjs,angular-ui-router,Angularjs,Angular Ui Router,当HTTP请求完成时,我尝试重定向到另一个带有我的应用程序参数的页面: app.controller("startSess", function($scope, $http, $window, $state){ var self = this; $scope.startNewSession = function(){ self.newSessionData = {"nick": thisScope.nic
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
在dotjem路由中发现它:
$state.goto('home',{/*可选:Params here*/})
和非:$state.go('blah',{/*可选:这里的参数*/})
那么$state中有什么?请张贴相关代码是关于最好的文件,我可以找到它。它已经在Angular中了。您如何包括ui路由器?请把那个密码寄出去。这就是我应用程序的其余部分。我把它全部正确地导入了。我可能应该注意到,我使用的是DotJem UI路由,我相信这与我试图在$http
请求中实现这一点有关?它只是被称为DotJem路由或DotJem角度路由(顺便说一句;)谢谢你提醒Jens!:D