Interpolation :
Pass data from component file to template called interpolation,We can pass variable & function to the template files like below,
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-topmenu',
template: `
{{name}}
{{getsirname()}}
`,
styles: []
})
export class TopmenuComponent implements OnInit {
public name = "Dharmendra Singh";
constructor() { }
ngOnInit() {
}
getsirname(){
return "rajput";
}}
Pipes :
Pipes are used to change the data before display on the view, like uppercase.lowecase,slice etc.
selector: 'app-topmenu',
template: `
{{name | uppercase}}
{{name | lowercase}}
{{ post | json }} //
...
`,
styles: []
ng foor loop in angular with add class dynamic on last element
<span *ngFor="let two of last_two; let last = last;">
<div class="single-top-post" [ngClass]="{'mt-10': last}"> .....
Here it will add the mt-10 class at the last element
Comments
Post a Comment