0

I have a template:

<div *ngFor="let article of articles">
  <h2>{{ article.title }}</h2>  
  <p>{{ article.authorName }}</p>
</div>

And i have a dataModel.ts file:

export interface IArticle {
  id: number
  title?: string
  authorName?: string}

How to write a directive that receives a string in the form of a name and checks whether the letters at the beginning of the surname and first name are capitalized, if not, then makes them large? Those: artur haiduk -> Artur Haiduk

R. Richards
  • 24,603
  • 10
  • 64
  • 64

1 Answers1

0

Use angular predefined pipe titlecase

   <div *ngFor="let article of articles">
         <h2>{{ article.title | titlecase }}</h2>  
         <p>{{ article.authorName | titlecase }}</p>
  </div>
Exception
  • 571
  • 1
  • 3
  • 15