我有一个带有一些表单的指令。通常这就是我需要的,但有时我需要添加更多的输入字段。因此,我尝试使用插入来实现,但它不起作用。
我创建了一个plunker来说明这一点:http://plnkr.co/edit/zNOK3SJFXE1PxsvUvPBQ?p=preview 该指令是一个简单的表单,包含输入字段、插入和一个按钮来帮助测试它(省略了不重要的部分)。
我创建了一个plunker来说明这一点:http://plnkr.co/edit/zNOK3SJFXE1PxsvUvPBQ?p=preview 该指令是一个简单的表单,包含输入字段、插入和一个按钮来帮助测试它(省略了不重要的部分)。
scope: {
},
transclude: 'element',
template:
'<form name="myForm">' +
'<input type="text" ng-model="data.inDirective"></input>' +
'<div ng-transclude></div>' +
'<button ng-click="showData()">show data</button>' +
'</form>'
这里是使用 transclusion 的示例:
<form-as-directive>
<input type="text" ng-model="data.inTransclude"></input>
</form-as-directive>
我能否在插槽中使用指令的作用域(scope)?