我想顯示在HTML代碼page.Version角度值的服務配置的值author
和version
顯示正常,但不是作者的名字 下面是HTML代碼Angularjs錯誤未知的提供
<!doctype html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>My AngularJS App</title>
<link rel="stylesheet" href="css/app.css"/>
</head>
<body>
<ul class="menu">
<li><a href="#/view1">view1</a></li>
<li><a href="#/view2">view2</a></li>
</ul>
<div ng-view></div>
<div>Angular seed app: v<span app-version></span></div>
<div>Author is : <span app-author></span></div>
<script src="lib/angular/angular.js"></script>
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
<script src="js/filters.js"></script>
<script src="js/directives.js"></script>
</body>
</html>
這裏是指導...
angular.module('myApp.directives', []).
directive('appVersion', ['version', function(version) {
return function(scope, elm, attrs) {
elm.text(version);
};
}])
.directive('appAuthor', ['author', function(author) {
return function(scope, elm, attrs){
elm.text(author);
};
}]);
,這裏是哪裏author
和version
值配置
angular.module('myApp.services', []).
value('version', '0.1')
.value('author','JIM');
我得到開發者控制檯中的錯誤是
Error: Unknown provider: authorProvider <- author <- appAuthorDirective
即使我被困在同樣的問題,我解決了它,但我一直得到同樣的問題。 請注意'函數getService(serviceName,調用者){if(cache.hasOwnProperty(serviceName))' 修復問題後**不要忘記做Ctrl + F5來清除瀏覽器緩存** – 2017-02-06 15:03:57