在我的應用程序已經宣佈Master.html NG-app並在其 添加的所有腳本,樣式表引用這是我的母版頁如何使用AngularJS
<html ng-app="mainApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>AdminLTE 2 | Dashboard</title>
<script src="../Angular/angular.min.js"></script>
<script src="../Angular/angular-route.js"></script>
<script src="../Scripts/AngularServices/App.js"></script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<li><a href="/main/Group"><i class="fa fa-circle-o"></i>Group</a></li>
<li><a href="/main/Member"><i class="fa fa-circle-o"></i>Member</a></li>
<section class="content">
<div ng-view></div>
</section>
</body>
</html>
保持母版頁頁面重載的HTML App.js
var mainApp = angular.module("mainApp", ['ngRoute'])
mainApp.config(function ($routeProvider, $locationProvider) {
$routeProvider.when('/main/Group', { templateUrl: '/Portal/Group.html', controller: 'GroupController' }),
$routeProvider.when('/main/Member', { templateUrl: '/Portal/Member.html', controller: 'MemberController' });
$locationProvider.html5Mode(true);
});
// group
mainApp.controller('GroupController', function ($scope, $http) {
$http.get('/api/APIGroup/GetGroupDetails').then(function (result) {
$scope.group = result.data;
});
});
Group.html
<div ng-controller="GroupController">
<div class="row">
<h1>Welcome to group</h1>
my content here
</div>
</div>
當我執行主PAG Ë如果母版頁中點擊鏈接組形式group.html開我的網址這樣
http://localhost:50810/main/chitGroup
但如果重載頁面在這裏我得到誤差
Server Error in '/' Application.
The resource cannot be found.
母版頁不適用於如何解決這個問題
請參考[本指南](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-與-html5mode)。 – 31piy