I have angular library with expose component call AComponent. AComponent has template and set of method and properties. Once angular library is package it is expose as nuget package so other projects can be used it.
@Component({
selector: 'xxx-editor',
templateUrl: './xxx.component.html',
styleUrls: ['./xxx.component.scss'],
})
export class AComponent implements OnInit {
......
......
logToConsole() {
console.log('trace for working');
}
}
I have a new requirement so for cater that requirement I want to expose one of the method logToConsole in AComponent to outside so relying party can call the method using the component.
Will say this library is used by BComponent and access as ViewChild inside *.ts file
BComponent - Template
<div style="text-align:center">
<h1>
Welcome to {{ title }}!
</h1>
<xxx-editor #xxxEditor [(ngModel)]="html" [editable]="true"
></xxx-editor>
</div>
BComponent - Ts
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
ngOnInit(): void {
this.editor.logToConsole();
}
title = 'editor-test';
html = 'sample test data';
@ViewChild('xxxEditor') editor: AComponent | null;
}
Problem is this.editor.logToConsole() logToConsole is undefined. Is it how design angular library? Is there anyway I can access this method?