我有一個模塊化應用程序,其中我有路由拆分成多個文件。Angular UI路由器重定向到默認頁面
所以我的系統是。
Top
--Main.Module.js
--Main.Routes.js
--Main.Controllers.js
--Main.html
--user (folder)
----User.Module.js
----User.Routes.js
----User.Controllers.js
和用戶文件夾,我有一個的login.html並用Register.html
主模塊文件夾註冊登錄文件夾看起來像這樣
angular.module('Main', ['ionic', 'Main.Routes', 'Main.Controllers', "User"])
.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);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
});
的主要路徑文件包含
angular.module('Main.Routes', [])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('Loader', {
url: '/',
templateUrl: '/views/Main.html',
controller: 'MainController'
});
$urlRouterProvider.otherwise('/');
});
而Main.Module.js注入這兩個東西以及U該js文件SER模塊看起來像這樣
angular.module('User', ['User.Controllers', 'User.Services', 'User.Routes']);
的用戶路徑文件有登錄頁面和註冊頁面的路徑
angular.module('User.Routes', [])
.config(function($stateProvider) {
$stateProvider
.state('Login', {
url: '/user/login',
templateUrl: 'views/user/login/Login.html',
controller: 'LoginController'
})
.state('Register', {
url: '/user/register',
templateUrl: 'views/user/register/Register.html'
});
// if none of the above states are matched, use this as the fallback
});
當我做$ state.go(「登錄」)從主控制器它將我帶到登錄頁面沒有任何問題。但是我有與代碼
//Move user to the register page
$scope.registerClick = function(){
$state.go("Register");
}
此塊會被重定向我到註冊頁面周邊半秒相關聯的登錄頁面上的註冊按鈕,然後立即回到了踢它的主要HTML頁面。所以我的問題是我需要知道爲什麼國家沒有留在註冊頁面,並立即移動到main.html頁面。註冊頁面是頁面歷史堆棧的一部分,因爲我可以通過硬件後退按鈕返回到它,或者在測試過程中按下回車鍵。我嘗試將路由移回主路由文件,而不是注入用戶路由,但它產生了相同的結果。
==============編輯============= 一旦應用程序加載,如果我改變頁面,它會去主頁面到註冊頁面,並添加一個鏈接回登錄頁面,這種行爲不會發生。我只是困惑什麼是不同的。
做'的console.log($ state.href( 「註冊」))',並告訴我們你得到了什麼? – Rachmaninoff
#/ user/register當從RegisterController完成 – SoulOfSet
如果我直接從地址欄去那個URL我沒有問題。這只是當我嘗試從登錄頁面重定向它是否有這個問題 – SoulOfSet