我的代码是这样的:
$scope.toCreate = function () {
console.log('create')
$state.go('createAccount')
}
$stateProvider.state('login', {
url:'/login',
templateUrl:'js/pages/login.html',
controller:'loginCtrl'
}).state('createAccout', {
url:'/createAccount',
templateUrl:'js/pages/createAccount.html',
controller:'createAccountCtrl'
})
浏览器控制台报错如下:
Error: Could not resolve 'createAccount' from state 'login'
at Object.transitionTo (http://localhost:63342/atMoon/www/lib/ionic/js/ionic.bundle.js:33795:39)
at Object.go (http://localhost:63342/atMoon/www/lib/ionic/js/ionic.bundle.js:33678:19)
at Scope.$scope.toCreate (http://localhost:63342/atMoon/www/js/controllers/loginCtrl.js:8:17)
at http://localhost:63342/atMoon/www/lib/ionic/js/ionic.bundle.js:18520:21
at http://localhost:63342/atMoon/www/lib/ionic/js/ionic.bundle.js:42067:9
at Scope.$eval (http://localhost:63342/atMoon/www/lib/ionic/js/ionic.bundle.js:20382:28)
at Scope.$apply (http://localhost:63342/atMoon/www/lib/ionic/js/ionic.bundle.js:20480:23)
at HTMLButtonElement.<anonymous> (http://localhost:63342/atMoon/www/lib/ionic/js/ionic.bundle.js:42066:13)
at http://localhost:63342/atMoon/www/lib/ionic/js/ionic.bundle.js:10674:10
at Array.forEach (native)
这是为什么
소개만
$state
服务,然后使用$state.go
하세요. 특정 매개변수에 대한 문서를 참조하세요: $state#go같은 문제가 발생했습니다!
으아아아$state 서비스를 도입했는데, 여전히 같은 문제가 발생하시나요?
$httpProvider 인터셉터
으아아아 으아아아angular.module('ngApp', ['ui.router'])
.config(함수($stateProvider, $urlRouterProvider) {
……
})
##
으아아아
createAccount.html
创建了吗?createAccountCtrl
이 JS 파일이 html에 도입됐나요?