Tom*_*thy 1 angularjs angularjs-directive
我有一个复杂的指令,我在许多HTML页面上使用我的应用程序.它变得复杂并包含嵌套结构,因此我将它复制并粘贴到任何地方:
<card ng-repeat="card in deck"
scalex="card.scalex"
scaley="card.scaley"
...
<img ng-repeat="wait in [] | range:card.f" src="symbol.png" style="position:absolute; left:{{(13*$index + 3 )}}px; z-index: 1;bottom:0px"></img>
...
<icon ng-repeat="icon in card.icons"
x="icon.x"
y="icon.y"
...
/>
</card>
Run Code Online (Sandbox Code Playgroud)
但是,并非总是将此指令绑定到变量"card".因此,在复制和粘贴后,我需要将许多作业从"card.bar"更改为"foo.bar".这有点劳动和容易出错.我想分配一个与foo具有相同状态的绑定变量卡.然后我不需要更改我保留的复制和粘贴源.
那么我可以在HTML中添加一个指令,将foo重新分配到卡片吗?