我有一个简单的代码:
原文链接:https://www.f2er.com/angularjs/144115.htmldefine(['app'],function(app) { app.factory('factoryProvider',function(){ return { name: 'my Name' } }); app.directive('myDiv',['factoryProvider',function(factoryProvider) { return { restrict: 'E',replace: true,templateUrl: 'link/to/template.html',controller: function($scope) { },link: function(scope,routeParams,location) { console.log(factoryProvider.name); } }; }]) });
我想要能够在链接功能中访问myFactory,但是我不能!我也尝试过link:function(scope,routeParams,location,factoryProvider),也没有工作。为什么?