小编Shi*_*har的帖子

Angularjs $ templateRequestProvider中的未知提供程序

我在index.html中包含其他html文件作为模板.为此我使用ng-view指令.但我收到一个错误: Unknown provider: $templateRequestProvider <- $templateRequest <- $route <- ngViewDirective 我使用的代码是:

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

以下是控制器:

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';
});
Run Code Online (Sandbox Code Playgroud)

配置:

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

    .when('/surveys', {
        templateUrl …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-directive

24
推荐指数
1
解决办法
2万
查看次数