angular.module('docsTransclusionExample',[]).controller('Controller',['$scope',function($scope){$scope.name='Tobias';}]).directive('myDialog',function(){return{restrict:'E',transclude:true,scope:{},templateUrl:'my-dialog.html',link:function(scope,element){scope.name='Jeff';}};});这个在官网上的directive代码,link函数起到的什么作用,解释有点费解,然后其中有三个参数scope:isanAngularscopeobject.element:isthejqLite-wrappedelementthatthisdirectivematches.attrs:isahashobjectwithkey-valuepairsofnormalizedattributenamesandtheircorrespondingattributevalues.这个用法是怎样的,scope好像就是return中得scope属性。。
aluckdog
相关分类