Есть ли способ использовать javascript для применения директивы ng-model к созданному элементу?В приведенном ниже коде я хочу, чтобы новый элемент select был привязан с помощью ng-модели к переменной области действия внутри контроллера:
angular.module('myApp').directive('dynamicHtml', function ($q, $http, $compile) {
return {
restrict: 'EAC',
scope: '=',
compile: function(element, attr) {
return function(scope, element, attr) {
var select = document.createElement('select');
// Here I want to use javascript to apply ng-model='controllerVar'
// to the new select element
element.append(select);
}
}
};
});