I am a first time angularjs user and I am trying to create a directive but I cannot get around this error:
Error: Unknown provider: $scopeProvider <- $scope <- someDirectiveDirective createInjector/providerInjector<@http://localhost:4242/js/lib/angular/angular.js:2734 getService@http://localhost:4242/js/lib/angular/angular.js:2862 createInjector/instanceCache.$injector<@http://localhost:4242/js/lib/angular/angular.js:2739 getService@http://localhost:4242/js/lib/angular/angular.js:2862 ... ... ...
I create my angular app as follows:
var app = angular.module(
"myApp",
...
I then try and create my directive in another file:
app.directive('someDirective', function($http, $scope, $element, $attrs) {
return {
restrict: "A",
Then I use the directive:
I am sure that I am doing something really dumb but I have no idea.
Try this:
app.directive('someDirective', function($http) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
}
};
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With