I have 2 model data objects which I added to $scope
. They are $scope.MyFieldModelData
and$scope.ScreenModelData.
ScreenModelData
is like:
0: Object
$$hashKey: "00R"
FieldName: "SomeLabelName"
FieldType: "label"
1: Object
$$hashKey: "00R"
FieldName: "SomeDropdownName"
FieldType: "dropdown"
And MyFieldModelData
is like:
SomeLabelName: "Hello World"
SomeDropdownName: Array[2] --this contains the dropdown data
I have to create a table with ng-repeat
and use these model data objects to dynamically add controls on each table row. Some of the rows will have labels, some will have dropdowns and some will have hyperlinks. But this is in completely random order, so I cannot hard code anything.
I am using the following HTML:
<table class="table">
<tbody>
<tr ng-repeat="MyData in ScreenModelData">
<td>
<label ng-show="MyData.FieldType == 'label'">{{MyFieldModelData[{{MyData.FieldName}}]}}</label>
<select ng-show="MyData.FieldType == 'dropdown'"
ng-options="MyDDLData.Code as MyDDLData.Description for MyDDLData in MyFieldModelData[{{MyData.FieldName}}]">
</select>
</td>
</tr>
</tbody>
</table>
This renders the table but render the label and html as: MyFieldModelData[SomeLabelName]
and for dropdown as MyFieldModelData[SomeDropdownName]
. But actually I wanted the actual value inside the label or the actual dropdown rendered on the screen.