I am trying to inject a service into a directive like below:
var app = angular.module('app',[]);
app.factory('myData', function(){
return {
name : "myName"
}
});
app.directive('changeIt',function($compile, myData){
return {
restrict: 'C',
link: function (scope, element, attrs) {
scope.name = myData.name;
}
}
});
But this is returning me an error Unknown provider: myDataProvider. Could someone please look into the code and tell me if I am doing something wrong?