刚开始使用angular假如编写的directive同时需要require多个model怎么办?
2 回答
Helenr
TA贡献1780条经验 获得超3个赞
给你一段刚好在用的代码参考下:
directive:
angular.module('imageupload', []).directive('myCustomer', function() { return { restrict: 'A', scope: { image: '=', resizeMaxHeight: '@?', resizeMaxWidth: '@?', resizeQuality: '@?', resizeType: '@?', selectedfile: '&onFileSelected' }, link: function postLink(scope, element, attrs, ctrl) { } }; });
html
<input type="file" name="file" class="upload" id="inputImage2" accept="image/*" image="image2" resize-max-height="300" resize-max-width="250" resize-quality="0.5" on-file-selected="transferedImage(imageResult)"/>
aluckdog
TA贡献1847条经验 获得超7个赞
app.directive('directveA',function(){}) .directive('directiveB',function(){}) .directive('directiveC',function(){ return { require:['directiveA','directiveB'] link:function(scope,element,attrs,ctrls){ var aCtrl=ctrls[0]; var bCtrl=ctrls[1]; //这样就可以访问依赖指令的控制器了 } }; });
- 2 回答
- 0 关注
- 699 浏览
添加回答
举报
0/150
提交
取消