Angularjs在$ templateRequestProvider未知提供商 [英] Angularjs unknown provider in $templateRequestProvider

查看:152
本文介绍了Angularjs在$ templateRequestProvider未知提供商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在内的其他HTML文件中的index.html模板。对于这个我使用NG-观点指令。但我得到一个错误:
 未知提供商:$ templateRequestProvider< - $ templateRequest< - $航线< - ngViewDirective
在code我用的是:

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 {}
});

下面是控制器:

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';
});

的配置:

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

    .when('/surveys', {
        templateUrl : 'pages/surveys.html',
        controller  : 'surveysController'
    });
$locationProvider.html5Mode(true);
});

这是HTML:

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

我在哪里丢失的?

Where am I missing?

推荐答案

完成。在大多数情况下,这将是角路线和angularjs是矛盾的版本。此后,它主要是坠毁的页面由于

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.

这篇关于Angularjs在$ templateRequestProvider未知提供商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆