Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angularjs unknown provider in $templateRequestProvider

Tags:

I am including other html files as template in index.html. For this i am using ng-view directive. But i am getting an error: Unknown provider: $templateRequestProvider <- $templateRequest <- $route <- ngViewDirective The code I am using is:

'use strict';  var surveyApp = angular.module('surveyApp',['ngRoute']);     surveyApp.factory('surveyFactory',function (){  return {} }); 

Here are the Controllers :

surveyApp.controller('profileController', function($scope,surveyFactory) {     // create a message to display in our view     $scope.message = 'This is the profile page'; });  surveyApp.controller('surveysController', function($scope,surveyFactory) {     // create a message to display in our view     $scope.message = 'This is the surveys page'; }); 

The Config:

surveyApp.config(function($routeProvider, $locationProvider) { $routeProvider     .when('/', {             templateUrl : 'pages/profile.html',         controller  : 'profileController'     })      .when('/surveys', {         templateUrl : 'pages/surveys.html',         controller  : 'surveysController'     }); $locationProvider.html5Mode(true); }); 

This is the HTML:

<body ng-app="surveyApp">     <div id="main">         <div ng-view></div>     </div> </body> 

Where am I missing?

like image 599
Shikhar Avatar asked Oct 06 '14 09:10

Shikhar


1 Answers

Done. In most of the cases it would be the versions of angular-route and angularjs were conflicting. After then, it mostly crashed the page due to continuous loop requests in

.when('/', {         templateUrl : 'pages/profile.html',     controller  : 'profileController' }) 

Every time it saw a '/', it redirected to the same page all over again and hence forming an infinite redirect loop. This should be used in the last so that the first ones are checked, and if something remains, then it sees the '/' route.

like image 98
Shikhar Avatar answered Dec 16 '22 03:12

Shikhar