0
如何使用角度来实现类似以下的内容?我试过几种技术,但文档不太多帮助...angularjs:实时指令
<div id="#parent">
<!-- this is component definition, won't be rendered -->
<component id="tbl">
<table>
<tbody>
<tr ng-repeat="item in env.items"><td>{{item.label}}</td></tr>
<tbody>
</table>
</component>
...
<!--
this should only work if a component is registered within this parent,
ie '#parent' and would render the component as defined above
-->
<component ref="table" env="myCtx" />
</div>
控制器会是这样的:
<script>
//ctrl definition
funcion Ctrl(scope) {
scope.myCtx = {
items: [{label: "xxx"}, {label: "yyy"}]
}
}
</script>
基本上,我要定义一个指令上的-fly,我希望它只能在#parent
节点内访问(尽管这是可选的)。我被卡住了,因为我希望能够在compile
函数或transclude
函数中注入角度感知 html(即,<h1>{{blah}}</h1>
)。