This article follows the first seven on the subject ANGULAR and deals with the language TypeScript:
- https://128mots.com/index.php/2020/02/29/angular-en-moins-de-128-mots-typescript-partie-3/
- https://128mots.com/index.php/2020/02/28/angular-en-moins-de-128-mots-partie-2/
- https://128mots.com/index.php/2020/02/27/angular-en-plus-de-128-mots-partie-1/
- https://128mots.com/index.php/2020/03/02/typescript-part4/
- https://128mots.com/index.php/2020/03/24/angular-en-moins-de-128-mots-typescript-partie-5/
- https://128mots.com/index.php/2020/03/25/angular-component/
- https://128mots.com/index.php/2020/03/27/typescript-angular-getter-setter/
Templates and interpolation
Interpolation is the incorporation of expressions into marked text. By default, interpolation uses double braces, ‘and ‘a’ as a delimiter.
<h3>Customer Number: 'numbereroClient'</h3>
Example of a directive with iteration:
<li *ngfor="let client of listeClients">'customer.name'</li>
Services:
The services allow to decouple the component of the call to a service, they are thus reusable.
ng generate customer service
import - Injectable - from '@angular/core'; @Injectable providedIn: 'root', }) export class ClientService constructor() }
The logic is then decoupled from the service which is injectable via the addiction injection.
Addiction injection
Example of injection of CustomerService dependency into a CustomerComponent component
import - Component, OnInit - from '@angular/core'; import 'Hero ' from '.. /hero'; import 'HeroService ' from '.. /hero.service'; import 'MessageService ' from '.. /message.service'; @Component selector: 'app-heroes', templateUrl: './heroes.component.html', StyleUrls:['./heroes.component.css'] }) export class ClientComponent implements OnInit ... getClients(): void this.clientService.getClients(); } }