I have a parent component
angular.module('app')
.component('parentComponent', {
template: `
<child-component data="myData"></child-component>
`,
I'm getting myData by asynchronous call
myMethod(params).then(data => {
$ctrl.data = data;
});
and then I pass it down to my child component where I want modify it and display it in the template
angular.module('app')
.component('childComponent', {
restrict: 'E',
replace: true,
templateUrl: '',
bindings: {
data: '='
},
controller: function () {
const $ctrl = this;
$ctrl.$onInit = function () {
console.log($ctrl.data);
}
});
Problem is that data gets passed in before it is received and because of it it is undefined in the child component.
I'm not sure how do I wait for the data before passing it down.
<child-component ng-if="data" ...>