您好,提前致谢。我正在努力让我的观点显示在我的 index.html 页面上。单击我的链接时,我可以在 http 请求中看到正在检索适当的模板,但它只是没有显示。就像将我的模板 html 与 ng-view 标签关联起来时遇到问题一样。我的模板也只有一个根元素,其他一切似乎都在正常工作。任何帮助将非常感激。此外,如果我只使用模板而不是 templateUrl 并以这种方式添加 html 也可以。
var app = angular.module('fireground', [ 'ngRoute', 'ngSanitize' ])
.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl : 'pages/test.html',
controller : 'RootCtrl'
})
.when('/one', {
templateUrl : 'pages/test2.html',
controller : 'RootCtrl'
})
.when('/newsletter', {
controller : 'RootCtrl',
templateUrl : 'pages/test3.html'
});
//.otherwise({
// redirectTo: '/one'
//});
}])
.controller('RootCtrl', function($scope){
$scope.messages = "Test Test Test Test Test Test";
})
还有我的 Index.html(瘦身)
<!DOCTYPE html>
<head>
<title>TheFireStore App</title>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, target-densityDpi=device-dpi" />
<link rel="stylesheet" href="./css/jquery.mobile-1.4.2.min.css" />
<link rel="stylesheet" href="./css/style.css" />
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular-sanitize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular-route.min.js"> </script>
<script type="text/javascript" src="./js/angular/app.js"></script>
<script type="text/javascript" src="./js/angular/factories.js"></script>
<script type="text/javascript" src="./js/angular/directives.js"></script>
<script type="text/javascript" src="./js/angular/services.js"></script>
</head>
<body data-ng-app="fireground">
<div id="slidemenu">
<ul id="slideUL">
<li><img class="doubleLine" src="./images/doublelines.jpg" /></li>
<li><a onclick="$(document).unbind('touchmove');" class="navlnk Left" href="#one" data-transition="slide">FIREGROUND LIVE <span class="floatR">»</span></a></li>
<li><img class="doubleLine" src="./images/doublelines.jpg" /></li>
<li><a href="">DEALS</a>
<ul style="margin:-15px 0 0 40px;">
<li><a onclick="$(document).unbind('touchmove');" class="navlnk Center" href="#products" data-transition="slide">Apparel</a></li>
<li><a onclick="$(document).unbind('touchmove');" class="navlnk Center" href="#products" data-transition="slide">PPE</a></li>
<li><a onclick="$(document).unbind('touchmove');" class="navlnk Center" href="#products" data-transition="slide">Helmets</a></li>
<li><a onclick="$(document).unbind('touchmove');" class="navlnk Center" href="#products" data-transition="slide">Boots</a></li>
<li><a onclick="$(document).unbind('touchmove');" class="navlnk Center" href="#products" data-transition="slide">Flashlights</a></li>
<li><a onclick="$(document).unbind('touchmove');" class="navlnk Center" href="#products" data-transition="slide">Tools</a></li>
<li><a onclick="$(document).unbind('touchmove');" class="navlnk Center" href="#products" data-transition="slide">Bags & Packs</a></li>
</ul>
</li>
</ul>
<ul>
<li><img class="doubleLine" src="./images/doublelines.jpg" /></li>
<li><a onclick="$(document).unbind('touchmove');" class="navlnk Right" href="#newsletter" data-transition="slide">NEWSLETTER<span class="floatR">»</span></a></li>
<li><img class="doubleLine" src="./images/doublelines.jpg" /></li>
<li><a href="http://www.thefirestore.com/mobile" rel="external">Shop TheFireStore.com <span class="floatR">»</span></a></li>
</ul>
</div>
<div id="master">
<div class="header" data-role="header" data-position="fixed">
<a href="#" class="navlinkstyle" data-slidemenu="#slidemenu" data-slideopen="true" data-corners="false" data-iconpos="notext"><img border="0" src="./images/imageMenu.jpg" /></a>
<img height="62" style="width:100%" class="imgCenter" src="./images/firegroundLogo.jpg" />
</div>
</div>
<div ng-view></div>
</body>
</html>
我的简单 html 模板是:
<h1 style="color:black">The message is: {{messages}}</h1>