in my Angular-App I try to use cookies to store some values. But I keep getting
Error: $injector:unpr Unknown Provider
Unknown provider: $cookiesProvider <- $cookies <- setlistCtrl
In my html-file, I reference angular-cookies:
<script src="Scripts/angular.min.js"></script>
<script src="Scripts/angular-cookies.js"></script>
<script src="app/app.js"></script>
<script src="app/setlist/setlistCtrl.js"></script>
In the app.js, I create the module and reference ngCookies
(function () {
myModule = angular.module('myAngularApplication', ['ngCookies']);
}());
In the controller in setlistCtrl.js, I inject $cookies
(function () {
var setlistCtrl = function ($scope, $http, $cookies) {
var that = this;
...
angular.module('myAngularApplication').controller('setlistCtrl', ["$scope", "$http", "$cookies", setlistCtrl]);
}
}());
I use Visual Studio 2013 and the AngularJS 1.4.3 packet installed via NuGet.
Any idea, what might be wrong?
Thanks in advance,
Frank
The problem was not within the code but with one of the next lines.
Instead of using the getter
angular.module('poModule').filter(...
I used the setter
angular.module('poModule', []).filter(...
Copy'n'paste without exactly knowing what you do is quite dangerous, especially when the developement system doesn't protect you from common pitfalls. I got the code from here: Angular JS Display String Array From Json
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.