I have to dynamically create a select list in angularjs directive. I have double quote ng-init and ng-options, using angular.element to create the element and append to a div with id preview. the code looks like followings
$('button').click(function() {
var ng_select_str = '<div class="col-sm-8" ng-init="options=[1,2,3]">' +
'<select class="form-control" id="inventory-qq" ng-model="inventory.qq" ng-options="opt as opt for opt in options"></select>' +
'</div>';
var element = angular.element(ng_select_str);
$('#preview').append(element);
});
however the select list render without any options value(empty select list). I wonder how to solve this problem.