我在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)