I have a directive that adds new options to a select.
For that i'm using:
let opt: any = angular.element(
'<option value="' + opcion.valor + '">' + opcion.texto + '</option>'
);
this.element.append(this.$compile(opt)(scope));
In latest angularJS Select value (read from DOM) is validated
Better to use select's in standard way,
BTW - If you really need this, remove validation by decorating selectDirective
as follows
Codepen: https://codepen.io/anon/pen/NapVwN?editors=1010#anon-login
myApp.decorator('selectDirective', function($delegate) {
let originalCtrl = $delegate[0].controller.pop();
$delegate[0].controller.push(function() {
originalCtrl.apply(this, arguments);
this.hasOption = function() {
return true;
}
})
return $delegate;
});