javascript - generate dropdown using angularJS controller -


i trying dynamically add dropdown using $sce.trustashtml() function getting empty list in ui. here code:

$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 loco in locomotiveslist'></select>");  } 

in html, want render table:

<table>   <tbody>     <tr ng-repeat="data in tabledata track $index">         <td ng-repeat="(k, p) in data track $index"><span ng-bind-html=p>{{p}}</span></td>     </tr>   </tbody> <a class="btn btn-danger" ng-click="addrowtrain()">add run</a> ... </table 

but displaying empty table, please help

you adding dynamically must not pass binding values instead pass complete json object.

it's working this example

md-select in angular material


Comments