【发布时间】:2016-08-01 04:59:34
【问题描述】:
我想制作一个菜单并在 div 部分中显示我所有的 .html。 但是当我点击链接时,什么都没有显示 - 没有反应。
这是我的 index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" ng-app="PrincipaleApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="format.css" media="all" />
<title>TitreV3</title>
</head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://code.angularjs.org/1.4.8/angular-route.min.js"></script>
<script src="app.js"></script>
<script src="controllers.js"></script>
<body>
<p class="titre">Titre V3</p>
<table class="structure">
<tr>
<td class="structuremenu">
<div class="menu" ng-init="names=['One','Two','Three','Four','Five']">
<table>
<tr ng-repeat="x in names">
<td>
{{ x }}
</td>
<td><a href="#/{{ x }}_OK">OK</a></td>
<td><a href="#/{{ x }}_NotOK">KO</a></td>
</tr>
</table>
</div>
</td>
<td class="structurecontenu">
<div ng-view></div>
</td>
</tr>
</table>
</body>
</html>
这里是我的 app.js:
var PrincipaleApp = angular.module('PrincipaleApp', ['ngRoute', 'PrincipaleAppControllers']);
PrincipaleApp.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/One_OK', {
templateUrl : 'One_OK.html',
controller: 'PrincipaleCtrl'
}).
when('/One_NotOK', {
templateUrl : 'One_NotOK.html',
}).
otherwise({
redirectTo : '/'
});
}]);
var lignes = angular.module('PrincipaleApp', []);
这里是我的 controllers.js
var PrincipaleAppControllers = angular.module('PrincipaleAppControllers', []);
PrincipaleAppControllers.controller('PrincipaleCtrl', ['$scope', function ($scope) {
$scope.name = 'world';
}]);
这里是 One_OK.html
<div ng-controller="PrincipaleCtrl">
<label>Nom :</label>
<input type="text" ng-model="name">
<br />
<h2>Hello {{ name }}!</h2>
</div>
对我来说,ngroute 在我的 app.js 中没问题
也许 div 我的 ng-view 在表格中无法正常工作?
感谢您的帮助:)
【问题讨论】:
标签: angularjs