ng-switch
ネストされた「ng-repeat」とディレクティブを使用して、提供された列定義と行データ (2 つの異なる JSON オブジェクト) に基づいてテーブルをレンダリングしているときにエラーが発生します。
「ng-repeat」ng-switch
を使用して、ラッパー要素を使用せずにテーブル セルをレンダリングする方法はありますか。
Error: [$compile:ctreq] Controller 'ngSwitch', required by directive 'ngSwitchWhen', can't be found!
ここに私のテーブルテンプレートがあります
<table id={{metaData.id}} name="{{metaData.name}}" class="{{metaData.classes}}">
<tbody>
<tr ng-repeat="record in data">
<td ng-repeat="col in metaData.columns" ng-switch on="col.type"
ng-switch-when="index"> {{record.$index + 1}} </td>
</tr>
</tbody>
とりあえず作った回避策
私は次の方法でテーブルを動的にng-if
レンダリングするために使用しています:cell
rows
<table id={{metaData.id}} name="{{metaData.name}}" class="{{metaData.classes}} vk-table" >
<tbody>
<tr ng-repeat="record in data | orderBy : sortBy : reverse">
<td ng-repeat-start="col in metaData.columns" ng-if="col.type == 'index'"> {{$parent.$parent.$index + 1}}. </td>
<td ng-if="col.type =='name'">{{record.name = [record.fname, record.mname, record.lname].join(' ') }}</td>
<td ng-if="col.type =='date'">{{record[col.dataKey] = toDate(record[col.dataKey]) | date : 'mediumDate'}}</td>
<td ng-if="col.type =='inMobile'">
<a href="tel:{{record[col.dataKey]}}">{{record[col.dataKey]}}</a>
</td>
<td ng-if="col.type =='email'">
<a href="mailto:{{record[col.dataKey]}}">{{record[col.dataKey]}}</a>
</td>
<td ng-if="col.type =='gender'">{{record[col.dataKey] == 'm' ? 'Male' : 'Female'}}</td>
<td ng-if="col.type =='place'">{{record[col.dataKey].name}}</td>
<td ng-repeat-end ng-if="!col.type">{{record[col.dataKey]}}</td>
</tr>
</tbody>
</table>
ng-switch
追加の要素を使用せずに同じ出力を得るにはどうすればよいですか?