Reputation: 4164
I just started learning AngularJS, and trying to use $route
to show different views but getting error in my console. Here is my code:
index.html
<!Doctype html>
<html ng-app="approute">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="">
<title>Search The Angles: {{people.name}}</title>
<link rel="stylesheet" href="css/main.css">
<script type="text/javascript" src="script/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="script/angular.min.js"></script>
<script type="text/javascript" src="script/angular-route.js"></script>
<script type="text/javascript" src="script/app.js"></script>
</head>
<body>
<input type="text" ng-model="test">{{test | json}}
<div ng-view></div>
<a href="#/path2">Html2</a>
</body>
</html>
And my script is as follows:
'use strict';
var approute = angular.module("approute", ['ngRoute']);
approute.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/path2', {
templateUrl: "partials/index2.html",
controller: "appCountroller"
})
.when('/', {
templateUrl: "partials/index1.html",
controller: "appCountroller"
})
.otherwise({
redirectTo: '/'
});
}]);
approute.controller("appCountroller", function($scope, $http) {
$http.get('../json/data.json').success(function(response) {
$scope.people = response;
});
});
index1 and index2.html are in following format:
<div>
<ul>
<li ng-repeat="person in people | filter:test">{{person.name}}</li>
</ul>
</div>
and index2.html
<div>
<ul>
<li ng-repeat="person in people | filter:test">{{person.name}}-{{person.position}}</li>
</ul>
</div>
When I tried opening in a browser, I get the following error on my console:
Error: [$injector:unpr] http://errors.angularjs.org/1.2.27/$injector/unpr?p0=%24templateRequestProvider%20%3C-%20%24templateRequest%20%3C-%20%24route%20%3C-%20ngViewDirective at Error (native)...
with reference to my angular.min.js file
I've checked everything I could, but not seeing what's causing the error.
Upvotes: 1
Views: 502
Reputation: 1093
It seems that dependencies cannot be resolve. In this case it look like it's about templateRequestProvider in ng-route.
Check that the version of angular-route and the version of angular are not conflicting, I think it might be that.
Upvotes: 1