为什么应用程序不显示 angular js 中的第一个视图
why the application not display the first view in angular js
我正在尝试在屏幕上显示我的第一个视图。我使用了 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
我会在回答中详细解释一下情况。
根据文档(otherwise() 部分):https://github.com/angular-ui/ui-router/wiki/URL-Routing
您可以将字符串(url 路径)或函数传递给 otherwise()。如果您想使用状态,您应该传递一个函数来调用该状态,如下所示:
$urlRouterProvider.otherwise(function($injector, $location){
$injector.invoke(['$state', function($state) {
$state.go('stateName'); //in you case 'signup'
}]);
它将调用状态服务并转到 'signup',其中路由配置为“/sign-up”。整体效果会一样。
我正在尝试在屏幕上显示我的第一个视图。我使用了 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
我会在回答中详细解释一下情况。 根据文档(otherwise() 部分):https://github.com/angular-ui/ui-router/wiki/URL-Routing
您可以将字符串(url 路径)或函数传递给 otherwise()。如果您想使用状态,您应该传递一个函数来调用该状态,如下所示:
$urlRouterProvider.otherwise(function($injector, $location){
$injector.invoke(['$state', function($state) {
$state.go('stateName'); //in you case 'signup'
}]);
它将调用状态服务并转到 'signup',其中路由配置为“/sign-up”。整体效果会一样。