【发布时间】:2015-03-31 15:51:21
【问题描述】:
这是我第一次尝试使用 ui-router。
这是我的 app.js
angular.module('myApp', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.config(function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise("/index.html");
$stateProvider.state('index', {
url: '/'
template: "index.html",
controller: 'loginCtrl'
});
$stateProvider.state('register', {
url: "/register"
template: "register.html",
controller: 'registerCtrl'
});
})
如您所见,我有两种状态。我正在尝试像这样注册状态:
<a ui-sref="register">
<button class="button button-balanced">
Create an account
</button>
</a>
但我得到了
无法从状态“”解析“注册”
异常。这里有什么问题?
【问题讨论】:
-
这有点傻,但我看到您正在创建模块“myApp”并将“ionic”列为依赖项,但是,我没有看到“ui-router”列为一个依赖。您是否将其包含在其他地方?
-
@deadbabykitten,由 ionic 负责。
-
@RogersSampaio - 我最近才发现,我以前没有使用过 ionic,但现在正在将它用于移动项目。真是不可思议。
标签: angularjs angular-ui-router