I am facing a problem... In my app I created directive that creates form fields. my idea is to pass a json object to directive with custom options for inputs, but I am expiriencing a problem with ng-model applying. Firstly here is my directive code:
.directive('formSelect', function () {
return {
transclude: true,
replace: true,
scope:{},
template: '<label class="acxm-dropdown {{opts.cssClass}}"><span>{{opts.labelText}}</span><select ng-transclude=""></select></label>',
restrict: 'E',
link: function (scope, element, attrs) {
scope.opts = scope.$eval(attrs.opts);
}
};
}
)
in scope.opts I would like to have an subObject with custom attributes that will be added to input, so my directive will be called:
<form-select opts="{labelText: 'active only', cssClass: 'acxm-p-horizontal acxm-u-inline active-filter', customAttrs: {'ng-model': 'onlyActive'}}"></form-select>
I tried to add ng-model attr to input dynamically but than it didn't work, I also tried to pass only the name of ng-model attr but I had also some issues... Is it possible to make it work? or not? Thanks for your help...