I have an originator template that refers the template its rendering. I have a method in the originating template which I want invoked in the child template (not sublassing the origin template component.ts in the reference component.ts because of some DI related reasons). How would I go about this?
originator.component.ts
export class OriginatorComponent implements OnInit {
.....
execute() {
// Execute some code
}
retrieve() {
// Execute some code
}
}
originator.component.html
<ng-container *ngIf="test === 'abc'">
<ng-container *ngTemplateOutlet="abcdef"></ng-container>
<ng-template #abcdef>
<foo-template></foo-template>
</ng-template>
foo.component.ts
@Component({
selector: 'foo-component',
templateUrl: './foo-component.component.html',
styleUrls: ['./foo-component.component.scss']
})
export class FooComponent implements OnInit {
.....
someMethod1() {
execute(); // <--- HOW DO I DO THIS? EXECUTE Originating templates method?
}
someMethod2() {
retrieve(); // <--- HOW DO I DO THIS? EXECUTE Originating templates method?
}
}