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>
)。