Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
194 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...