我可以在角度指令中執行ng-view嗎?我試過,但顯示這個錯誤。ng route not working directive
錯誤:[$注射器:unpr] http://errors.angularjs.org/1.2.13/ $注射器/ unpr P0 =%24templateRequestProvider%20%3 C-%20%24templateRequest%20%3 C-%20%24route%20%3 C-%20ngViewDirective
?我的代碼:
的index.html
<body ng-app="Learning">
<div ng-controller="learning">
<div ng-switch-when="1" >
<div introduction-page></div>
</div>
</div>
</body>
app.js
var Learn = angular.module("Learning",['ngRoute']);
Learn.directive("introductionPage", function() {
return {
restrict:'EA',
transclude:false,
templateUrl:'views/intro.html',
replace:true,
controller: introController
}
function introController($scope,$http,$location) {
$scope.onClick = function() {
$location.path('course');
}
}
});
Learn.config(function($routeProvider) {
$routeProvider
.when('/course', {
templateUrl : 'views/course-ch1.html',
controller : 'courseController'
})
.otherwise({redirectTo: '/'});
});
function courseController($scope) {
alert("in course");
}
intro.html
<div style="width:100%;height:662px">
INTRODUCTION........
<div ng-view></div>
<input type="button" style="width:100px;height:40px;" label="enter" ng-click="onClick()">
</div>
是否有可能做到這一點呢?
感謝
你應該在index.html中使用ngView而不是intro.html –
是否可以在intro.html中使用ng-view?我可以在這裏做嗎?這是對的嗎? –
我不認爲這樣用... –