Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Reusable text not showing

I have a component that has some text that I want to reuse in another compnent however it is not showing for me

Here is my code

Reusable component

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

TS

@Component({
  selector: 'header-bar',
  templateUrl: 'header-bar.component.html',
})
@Input() text: string = '';

HTML

<ng-template #headerTemplate>
            <span>{{ text }}</span>
</ng-template>

Component I want to use the header bar in
TS

public text: string = "my text";

HTML

<header-bar [text]="text"></header-bar>

I don’t see nay error or any thing showing up. Any idea what I am mising?

>Solution :

I don’t know why you are using ng-template ideally the template should just be :-

<span>{{ text }}</span>

If you still want to use ng-template you can use it like :-

<ng-template [ngIf]="true" #headerTemplate>
            <span>{{ text }}</span>
</ng-template>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading