Tôi bao gồm các tệp html khác làm mẫu trong index.html. Đối với điều này tôi đang sử dụng ng-xem chỉ thị. Nhưng tôi đang nhận được một lỗi: Unknown provider: $templateRequestProvider <- $templateRequest <- $route <- ngViewDirective
Mã Tôi đang sử dụng là:
'use strict';
var surveyApp = angular.module('surveyApp',['ngRoute']);
surveyApp.factory('surveyFactory',function(){
return {}
});
Dưới đây là 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';
});
Các 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);
});
Đây là HTML :
<body ng-app="surveyApp">
<div id="main">
<div ng-view></div>
</div>
</body>
Tôi bị thiếu ở đâu?
Bạn đã thêm tệp angular-route.js ??? –
Có. Tôi đã thêm tệp angular-route.min.js tải và không có lỗi của bất kỳ tập lệnh bị thiếu nào ở đó. – Shikhar