Ich versuche, eine Drop-Down mit $sce.trustAsHtml()
Funktion dynamisch hinzuzufügen, aber ich bekomme eine leere Liste in der Benutzeroberfläche. Hier ist der Code:Dropdown-Befehl mit angularJS Controller generieren
$scope.addRowtrain = function() {
$scope.locomotivesList = [{"name": "loco1", "value":"1"}, {"name": "loco2", "value":"2"}];
tableData[id] = $sce.trustAsHtml('CTRun'+counter++);
tableData[type] = $sce.trustAsHtml("<select data-ng-model='selectedLoco' data-ng-options='loco.name for loco in locomotivesList'></select>");
}
Im HTML, möchte ich es als Tisch machen:
<table>
<tbody>
<tr ng-repeat="data in tableData track by $index">
<td ng-repeat="(k, p) in data track by $index"><span ng-bind-html=p>{{p}}</span></td>
</tr>
</tbody>
<a class="btn btn-danger" ng-click="addRowtrain()">Add Run</a>
...
</table
aber es ist eine leere Tabelle angezeigt wird, bitte helfen
Sollte nicht 'tableData' arbeiten:' $ scope.tableData'? – m0ngr31
oh sorry ich habe die Zeile verpasst, tableData ist ein Objekt, danach erstelle ich ein Array als $ scope.tableData.push (tableData); – LIQvID