2013-10-01 36 views

回答

2

可以使用這樣的函數

<ul ng-repeat="lay in lays"> 
    <li ng-repeat="color in colors">{{render(lay, $index, color)}}</li> 
</ul> 

$scope.render = function (lay, index, color) { 
    if (lay == 0 && index == 0) return color; 
    else return "white"; 
} 
0
<ul ng-repeat="lay in lays"> 
    <li ng-repeat="color in colors"> 
     {{ (lay == 0) && (($index == 0) && color || "white") || "white" }} 
    </li> 
</ul> 

無需使用控制器。

+0

如何測試您的代碼? – zsong

+0

@sza我已經完成了類似的項目。如果魯珀特可以提供一個jsfiddle,我可以證明給你。 – geniuscarrier

+0

我在說單元測試。 – zsong

1

在我看來,你應該在控制器中過濾你的數據,它的更全面和更好的維護。