I want to pass argument to directive in angularjs.
I found some thread on stackoverflow Angularjs - Pass argument to directive
But it is not helped me.
Directive:
app.directive('datePicker', function () {
return {
restrict: 'E',
replace: true,
template: '<input type="text" class="form-control" ng-model="modelValue">',
scope: {
modelValue: '=',
format: '@',
},
link: function (scope, element, form) {
$(element).datepicker({
dateFormat: format,
});
}
}
})
Element:
<date-picker model-value="salary.month" format='MM-YYYY'></date-picker>
Here I want to use format
as attribute to pass directive
, So I can use same date-picker
directive with different format.
I have tried with above code example,model value is working but format is not working.
Please help me to find solution