我有一个像这样的元素:
<input test class="foo bar" ng-model="foo" name="foo"/>
当它具有“ test”属性时,我正在尝试将其转换为类似于下面的示例:
<div class="something">
<input type="text" class="foo bar" ng-model="foo" name="foo"/>
<span>test</span>
</div>
但是我在包含问题上遇到了问题,而不是将属性转移到输入中,而是将它们转移到了div中,所以我最终得到了以下结果:
<div class="something foo bar" type="text" ng-model="foo" name="foo">
<input/>
<span>test</span>
</div>
这是指令:
.directive('test', [function () {
return {
transclude:true,
replace:true,
template:'<div class="something">\
<input ng-transclude>\
<span>hi</span>\
</div>',
link: function (scope, element, attrs, ngModel) {
// do stuff
}
}
}])
显然,可以从AngularJS irc频道中获得Foxandxss的链接。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句