Próbuję wyświetlić skonfigurowane wartości author
i version
serwisu wartości kątowej w HTML kod page.Version wyświetlany jest w porządku, ale nie nazwę autor Oto kod HTMLbłąd angularjs Nieznany dostawca
<!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>
Oto dyrektywa ...
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);
};
}]);
a oto część usługa gdzie author
i version
wartości są skonfigurowane
angular.module('myApp.services', []).
value('version', '0.1')
.value('author','JIM');
Błąd Dostaję w konsoli programisty jest
Error: Unknown provider: authorProvider <- author <- appAuthorDirective
Nawet gdy utknąłem w tym samym numerze, naprawiłem go, ale ciągle miałem ten sam problem. Zwróć uwagę, że 'function getService (serviceName, caller) { if (cache.hasOwnProperty (serviceName))' Po naprawieniu problemu ** nie zapomnij zrobić Ctrl + F5, aby wyczyścić pamięć podręczną przeglądarki. ** –