I'm sorry if it a duplicate of someone question, however I can't find solution to my problem.
I want to make incapsulated component and provide data throw a function to main controller but all my argumnts are undefined. Seems I did something wrong.
Here is code
component:
(function () {
'use strict';
angular
.module('app')
.component('datePicker', {
template: createTemplate(),
controllerAs: 'vm',
bindings: {
onSelectDate: '&'
},
controller: DatepickerController
});
function DatepickerController() {
var vm = this;
vm.filterDateFrom = new Date();
vm.filterDateTo = new Date();
vm.submitDate = submitDate;
function submitDate() {
console.log(vm.filterDateFrom); // here I got dates from and to
console.log(vm.filterDateTo);
vm.onSelectDate(vm.filterDateFrom, vm.filterDateTo)
}
}
}
})();
main template
<date-picker
on-select-date="ctrl.submitFilter(from, to)">
</date-picker>
main controller
function submitFilter(from, to) {
console.log(from, to) // here all arguments are undefined
}