我试图在屏幕上显示我的第一个视图。我使用了angular的所有概念。但是它不显示或加载我的模板。我没有收到任何错误。但是它没有加载到html上,为什么这是我的代码
(function() {
'use strict';
angular.module('app.auth').config(Routes);
Routes.$inject = ['$stateProvider', '$urlRouterProvider'];
function Routes($stateProvider, $urlRouterProvider) {
console.log("config call")
// Default
$urlRouterProvider.otherwise('signin');
// Application
$stateProvider
.state('signin', {
url: '/sign-in',
templateUrl: 'js/auth/template/login.html',
controller: 'authenticationCntrl'
})
}
})();
其实我的login.html无法加载为什么?为什么它不加载..
这是我的项目https://dl.dropbox.com/s/x8s0xbllm270rq5/firstfroject.zip?dl=0
我将在回答时对此情况做更多解释。根据do docs(otherwise()部分):https : //github.com/angular-ui/ui-router/wiki/URL-Routing
您可以将字符串(URL路径)或函数传递给else()。如果您想使用状态,则应传递一个将调用该状态的函数,如下所示:
$urlRouterProvider.otherwise(function($injector, $location){
$injector.invoke(['$state', function($state) {
$state.go('stateName'); //in you case 'signup'
}]);
它将调用状态服务并转到“注册”,该路由的路由配置为“ / sign-up”。总体效果将是相同的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句