我有这个HTML:
<div data-ng-repeat="curService in sCtrl.myServices" class="ng-cloak" data-ng-if="sCtrl.service==curService.name">
<br />
<div id="curService.grid"></div>
</div>
和这个Angular:
ctrl.myServices = [
{
name: "Service1",
grid: "grid1",
controller: "Controller1 as ctrl1"
},
{
name: "Service2",
grid: "grid2",
controller: "Controller2 as ctrl2"
}
];
我希望curService.grid
转换为相应的字符串,并将此字符串作为内部div
的ID。有没有办法做到这一点?
编辑:我还想设置ng-controller="{{curService.controller}}"
,但这种语法似乎不起作用。有什么提示吗?
答案 0 :(得分:3)
这比你想象的要容易得多!
<div id="{{ curService.grid }}"></div>