我正在爲POC工作,我無法找到隱藏在這裏的任何愚蠢錯誤。我有一個裸機/基本的角應用程序,使用ui路由器。 Plunker可以在here找到。使用ui路由器的基本Angular應用不會加載登錄
在Chrome控制檯中,我可以看到我的app.module正在創建,但是登錄頁面從不出現。這是一個非常非常基本的應用程序,所以我認爲它一定是我錯過的簡單東西。有什麼建議麼?下面是一個快速示例:
config.js
(function() {
'use strict'
var app = angular.module('app.core');
app.config(AppRouter);
AppRouter.$inject = ['$stateProvider', '$urlRouterProvider'];
function AppRouter($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('login');
$stateProvider
.state('/', {
templateUrl: 'login.html',
controller: 'LoginController',
controllerAs: 'vm',
})
.state('login', {
templateUrl: 'login.html',
controller: 'LoginController',
controllerAs: 'vm',
});
}
})();
login.controller.js
(function() {
'use strict';
var app = angular.module('app.login');
app.controller('LoginController', LoginController);
LoginController.$inject = ['$location', '$filter', '$window', '$rootScope'];
function LoginController($location, $filter, $window, $rootScope) {
var init = function() {
console.log('here');
};
init();
}
})();
app.module.js
(function() {
var app = angular.module('app', ['app.core', 'app.login']);
})();
個login.module.js
(function(){
'use strict'
var app = angular.module('app.login', ['app.core']);
})();
core.module.js
(function(){
'use strict'
var app = angular.module('app.core', ['ui.router']);
})();
完美的工作,謝謝。獲得的教訓 - 從小開始:) – NealR
@NealR我很高興聽到它:) –