2016-04-04 5 views
2

Я получаю ошибку Uncaught Ошибка: [$ Инжектор: modulerr]

Я включил ниже JS файлы

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script> 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script> 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-resource.min.js"></script> 
    <script src="lib/jquery-1.12.1.min.js"></script> 

и мой JS код

angular.module('website',['ngRoute','ngResource']). 
    config(function($routerProvider){ 
     $routerProvider. 
      when('/about',{template:'templates/about.html'}), 
      when('/careers',{template:'templates/careers.html'}), 
      when('/signup',{template:'templates/signup.html'}), 
      otherwise({redirectTo : '/home', template:'/home.html'}) 
    }) 

function mainController($scope){ 

} 

Кто-нибудь, пожалуйста, помогите мне, где мне не хватает.

EDITED: журнал ошибок Не удалось создать экземпляр веб-модуля из-за: Ошибка: [$ Инжектор: unpr]? http://errors.angularjs.org/1.4.5/ $ форсунка/unpr p0 =% 24ro ... при Error (родной) на https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:6:416 в https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:40:307 при г (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:38:308) в Object.e [как Invoke] (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:39:64) при г (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:37:279) в https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:37:403 при п (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:7:322) при г (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:37:180) на ЕВ (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:40:435

+2

Две вещи: 1) Похоже, вы ссылаетесь на разные версии каждой Угловой библиотеки. Выберите одну версию и используйте ее для всех ссылок. 2) Когда вы отлаживаете, не используйте мини-версии. Использование недопустимых версий при отладке даст вам гораздо более подробные сообщения об ошибках. – Lex

+0

вы можете опубликовать свой журнал ошибок? –

ответ

3

Working Plnkr

Изменение $routerProvider к $routeProvider. Заменить , на . в конфигурации. Например:

when('/about',{template:'templates/about.html'}), 
when('/careers',{template:'templates/careers.html'}) 

к

when('/about',{template:'templates/about.html'}) 
.when('/careers',{template:'templates/careers.html'}) 

Ваш код JavaScript должен выглядеть следующим образом:

var website = angular.module('website',['ngRoute','ngResource']); 

    website.config(function($routeProvider){ 
     $routeProvider. 
      when('/about',{template:'templates/about.html'}) 
      .when('/careers',{template:'templates/careers.html'}) 
      .when('/signup',{template:'templates/signup.html'}) 
      .otherwise({redirectTo : '/home', template:'/home.html'}) 
    }) 

website.controller('mainController', function($scope){ 

}); 

Для получения дополнительной информации, please have a look at this example.

Надеюсь, что решите вашу проблему.

 Смежные вопросы

  • Нет связанных вопросов^_^