AngularJS 不呈现 $routeProvider 中指定的视图
AngularJS doesn't render view specified in $routeProvider
var myApp = angular.module("myApp", ["ngRoute"]);
myApp.config(function ($locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
});
myApp.config(function ($routeProvider) {
$routeProvider
.when("", {
templateUrl: "Views/Employee/Employees.html",
controller: "EmployeesController"
}).otherwise({ redirectTo: 'Views/Employee/Employees' });
});
它路由 otherwise 中提到的 URL,而不是 .when
中提到的 URL
您的 Angular 应用的根路由将是 "/"
,而不是 ""
。
然后,redirectTo
将您的路线提供商中定义的路线作为值。
myApp.config(function ($routeProvider) {
$routeProvider
.when("/", {
templateUrl: "Views/Employee/Employees.html",
controller: "EmployeesController"
})
.otherwise({ redirectTo: '/' });
});
var myApp = angular.module("myApp", ["ngRoute"]);
myApp.config(function ($locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
});
myApp.config(function ($routeProvider) {
$routeProvider
.when("", {
templateUrl: "Views/Employee/Employees.html",
controller: "EmployeesController"
}).otherwise({ redirectTo: 'Views/Employee/Employees' });
});
它路由 otherwise 中提到的 URL,而不是 .when
中提到的 URL您的 Angular 应用的根路由将是 "/"
,而不是 ""
。
然后,redirectTo
将您的路线提供商中定义的路线作为值。
myApp.config(function ($routeProvider) {
$routeProvider
.when("/", {
templateUrl: "Views/Employee/Employees.html",
controller: "EmployeesController"
})
.otherwise({ redirectTo: '/' });
});