2015-11-23 3 views
0

Я пытаюсь реализовать маршрутизацию в своем проекте, но мне трудно это сделать. Вот мой index.html кодngRoute: невозможно прочитать свойство 'module' of undefined

<!DOCTYPE html> 

<!-- Angular Material CSS now available via Google CDN; version 0.11.2 used here --> 
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/0.11.2/angular-material.min.css"> 
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-route.min.js"></script> 
<!--<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular-route.js"></script>--> 

<!-- Angular Material Dependencies --> 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script> 
<script type="text/javascript" src="./app/app.js"></script> 

<section ng-controller="MainCtrl"> 
    <div ng-view></div> 
</section> 


<!-- Angular Material Javascript now available via Google CDN; version 0.11.2 used here --> 
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.11.2/angular-material.min.js"></script> 

и вот мой app.js файл:

(function(){ 
    "use strict"; 

    var app = angular.module('math_teacher', ['ngMaterial']); 
    app.config(['$routeProvider', function($routeProvider){ 
    $routeProvider. 
    when('/welcome',{ 
     templateUrl: 'welcome.html', 
     controller: 'MainCtrl', 
    }). 
    otherwise({redirectTo: '/welcome'}); 
    }]); 

    app.controller('MainCtrl', ['$scope', function(){ 

    }]); 
    app.controller('TutorialsController', ['$scope', function(){ 
    }]); 
})(); 

и вот мой welcome.html, чтобы проверить, был ли мой маршрут работает

<h1>Welcome to this page</h1> 
<p>This really shows that the route is at work</p> 

на управлении это на моем сервере вот что я вижу в моей консоли:

Uncaught TypeError: Cannot read property 'module' of undefined(anonymous function) @ angular-route.js:24(anonymous function) @ angular-route.js:6

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/ $injector/modulerr?p0=math_teacher&p1=Er…gleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.3.15%2Fangular.min.js%3A38%3A135)(anonymous function) @ angular.js:38(anonymous function) @ angular.js:4138r @ angular.js:323g @ angular.js:4099ab @ angular.js:4025d @ angular.js:1452uc @ angular.js:1473Jd @ angular.js:1367(anonymous function) @ angular.js:26304a @ angular.js:2762c @ angular.js:3032

Pls помощь

ответ

1

Вы должны включить модуль 'ngRoute' в свое приложение.

var app = angular.module('math_teacher', ['ngMaterial', 'ngRoute']); 
3

Я нашел решение! после добавления «ngRoute» зависимостей она по-прежнему не работает

Все, что я сделал, чтобы добавить свой сценарий после angularjs сценария, а не до того, как