Angularjs 使用ng view进行初始渲染失败

Angularjs 使用ng view进行初始渲染失败,angularjs,Angularjs,下面显示的AngularJS代码在html中没有ng viewlast(最后一行)的情况下运行良好。这是第一页 此页面中只有一个ng视图。使用ng视图初始呈现此页面需要什么路由器设置?请注意,我还没有在本页中进一步介绍 <body ng-app="librarysystem" > <div class="container-fluid" ng-controller="SearchListCtrl"> <h3 class="text-muted">

下面显示的AngularJS代码在html中没有ng viewlast(最后一行)的情况下运行良好。这是第一页

此页面中只有一个ng视图。使用ng视图初始呈现此页面需要什么路由器设置?请注意,我还没有在本页中进一步介绍

<body ng-app="librarysystem" >


<div class="container-fluid" ng-controller="SearchListCtrl">

    <h3 class="text-muted">{{theDate  | date : "fullDate"}}</h3>
  <div class="jumbotron">
    <h3>Library System</h3>
  </div>
      <input ng-model="titleFilter"> Title Filter: {{ titleFilter }}
      <table class="table-responsive table table-striped table-bordered table-condensed table-hover">
        <thead>
          <tr><th colspan="3">Book Shelf</th></tr>
        </thead>
        <tbody>
          <tr ng-repeat="book in books | filter:titleFilter">
            <td><a href="#/data/{{$index + 1}}" class="thumb">{{$index + 1}}</a></td>
            <td class="col-sm-4">
              {{book.genre}}
            </td>
            <td class="col-sm-4">{{book.title}}</td>
            <td class="col-sm-4">{{book.author}}</td>
          </tr>
        </tbody>
      </table>
   </div> <!-- /container -->
  <div id="two">
  <div ng-view></div>
  </div>

</body>

Error: [$injector:unpr] Unknown provider: $templateRequestProvider <- $templateRequest <-      
$route <- ngViewDirective
http://errors.angularjs.org/1.2.26/$injector/unpr?p0=%24templateRequestProvider%20%3C-  
%20%24templateRequest%20%3C-%20%24route%20%3C-%20ngViewDirective
at VALIDITY_STATE_PROPERTY (http://localhost:8080/lib/angular/angular.js:78:12)
at http://localhost:8080/lib/angular/angular.js:3802:19
at Object.getService [as get] (http://localhost:8080/lib/angular/angular.js:3930:39)
at http://localhost:8080/lib/angular/angular.js:3807:45
at getService (http://localhost:8080/lib/angular/angular.js:3930:39)
at Object.invoke (http://localhost:8080/lib/angular/angular.js:3957:13)
at http://localhost:8080/lib/angular/angular.js:3808:37
我的路由器就是这些

var module = angular.module('librarysystem',['ngRoute','librarysystemcontroller','libraryServices','libraryFilters']);

module.config(['$routeProvider',
function($routeProvider) {
    $routeProvider.
        when('/search', {
            templateUrl: 'partials/searchlist.html',
            controller: 'SearchListCtrl'
        }).
        when('/',{
            template: '<p>{{text}}</p>',
            controller: 'controllerTwo'
        }).
        when('/data/:bookId', {
            templateUrl: 'partials/data.html',
            controller: 'BookAdditionCtrl'
        }).
        otherwise({
            redirectTo: '/search'
        });
}])

更新:我使用了与bower相同版本的angular JS文件。即使我使用bower,我也无法复制相同版本的所有文件。

您需要安装ng route库,并将其作为依赖项添加到angular应用程序中。 路由被分离到它自己的库中

通过Bower安装:

bower install angular-route@X.Y.Z
参考脚本:

<script src="angular-route.js">
编辑 该错误输出一个url,该url提供了大量有用的信息。

错误消息是:

Unknown provider: $templateRequestProvider <-  $templateRequest <- $route <- ngViewDirective

是否安装了ng路由模块?控制器2是否拼写正确?还有一个脚本标签,包含在当前页面中?是的。包括angular-route.js。所有控制器都包含在一个JS中。SearchListCtrl包含在同一个JS文件中,工作非常完美。var module=angular.module'librarysystem'、['ngRoute'、'librarysystemcontroller'、'libraryServices'、'libraryFilters'];angular-route.js也包括在内。你能分享controllerTwo的代码吗?可能它缺少一个依赖项。实际上除了范围变量初始化之外,controllerTwo的代码中没有任何内容。事实上,我不知道为什么没有周围的@MohanRadhakrishnan see Edit2也不起作用。。。我想也许你的路线代码有缺陷。
Unknown provider: $templateRequestProvider <-  $templateRequest <- $route <- ngViewDirective
angular
.module('librarysystem')
.config(['$routeProvider',
 function($routeProvider) {
   // Route Code
 }