我试图将服务注入如下指令:
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;
}
}
});
但这给我返回了一个错误Unknown provider: myDataProvider
。有人可以调查一下代码,并告诉我是否做错了什么?