I defined simple directive as you can see below:
(function () {
'use strict';
angular
.module('myApp')
.directive('biSelect', biSelect);
function biSelect($compile) {
var directive = {
restrict: 'E',
templateUrl: 'bi-select.html',
scope: {
required: '=?required'
},
controller: BiSelectController,
controllerAs: 'vm'
};
return directive;
}
function BiSelectController() {
var vm = this;
}
})();
and this is directive template:
<select class="form-control">
<option value=""></option>
</select>
now i want to add required attribute to select in directive when it was passed to directive, for example:
<bi-select required></bi-select>
how can i do that?
ng-modelattribute before worrying about therequiredattribute. Read AngularJS Developer Guide - Implementing custom form controls (usingngModel)