简体   繁体   English

Angular JS:错误:[$ injector:unpr]

[英]Angular JS: Error: [$injector:unpr]

please don't mark as duplicate i visited some previous question related to this and everything look nice to me but still getting this error. 请不要标记为重复我访问了一些以前与此相关的问题,一切看起来不错,但仍然收到此错误。 please help. 请帮忙。 i am very new to angularjs 我对angularjs很新

index.html 的index.html

<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
    <meta charset="UTF-8">
    <title>Angular JS</title>
    <script src="lib/angular.min.js"></script>
    <script src="lib/angular-route.min.js"></script>

    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <link rel="stylesheet" href="css/style.css" />
</head>
<body>
    <div class="main" ng-view></div>
</body>
</html>

list.html list.html

<ul class="artistlist">
    <li class="artist cf" ng-repeat="item in artists | filter:artistFilter | orderBy:artistOrder:direction">
        <img ng-src="images/{{item.shortname}}_tn.jpg" alt="{{item.name}}">
        <div class="info">
            <h2>{{item.name|uppercase}}</h2>
            <h3>{{item.reknown}}</h3>
        </div>
    </li>
</ul>

app.js app.js

var myApp = angular.module('myApp',['ngRoute','artistControllers']);

myApp.config(['$routeProvider', function($routeProvider) {
    $routeProvider.when('/list', {
        templateUrl: 'partials/list.html',
        controller: 'ListController'
    }).otherwise({
        redirectTo: '/list' 
    });
}]);

controllers.js controllers.js

var artistControllers = angular.module('artistControllers', []);

artistControllers.controller('ListController', ['$scope', '$http', function($scope, $http) {
    $http.get('data.json').success(function(data) {
        $scope.artists = data;
        $scope.artistOrder = 'name'
    });
}]);

full error 完全错误

Error: [$injector:unpr] http://errors.angularjs.org/1.2.9/$injector/unpr?p0=%24templateRequestProvider%20%3C-%20%24templateRequest%20%3C-%20%24route%20%3C-%20ngViewDirective
    at Error (native)
    at http://localhost/angular/lib/angular.min.js:6:449
    at http://localhost/angular/lib/angular.min.js:32:125
    at Object.c [as get] (http://localhost/angular/lib/angular.min.js:30:200)
    at http://localhost/angular/lib/angular.min.js:32:193
    at c (http://localhost/angular/lib/angular.min.js:30:200)
    at Object.d [as invoke] (http://localhost/angular/lib/angular.min.js:30:417)
    at http://localhost/angular/lib/angular.min.js:32:211
    at c (http://localhost/angular/lib/angular.min.js:30:200)
    at Object.d [as invoke] (http://localhost/angular/lib/angular.min.js:30:417)

Thanks for providing the error message. 感谢您提供错误消息。 Without it, it would have been near impossible to find the error. 没有它,几乎不可能找到错误。

I think this might help you: https://stackoverflow.com/a/26230442/3741957 我认为这可能会对您有所帮助: https//stackoverflow.com/a/26230442/3741957

(There seems to be a version mismatch of angular/ngRoute) (似乎有角度/ ngRoute的版本不匹配)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM