home.component.ts
import { Component, OnInit } from "@angular/core";
@Component({
selector: "Home",
moduleId: module.id,
templateUrl: "./home.component.html",
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
silabusList = [
{ "subject": "tamil" },
{ "subject": "hindi" },
{ "subject": "hindi" },
{"subject": "english"},
{ "subject": "spanish" },
]
constructor() {
}
ngOnInit(): void {
}
btn(args) {
console.log("index subje " + args)
}
}
home.component.html
<ActionBar title="Home" class="action-bar">
</ActionBar>
<ScrollView class="page">
<StackLayout class="home-panel">
<StackLayout *ngFor="let item of silabusList ; let i = index">
<Label [text]="item.subject" (tap)="btn(i)" ></Label>
</StackLayout>
</StackLayout>
</ScrollView>
Using ng-template
<ng-template ngFor let-item [ngForOf]="silabusList">
<Label [text]="item.subject"></Label >
</ng-template>
{ "subject": "spanish" },
]
constructor() {
}
ngOnInit(): void {
}
btn(args) {
console.log("index subje " + args)
}
}
home.component.html
<ActionBar title="Home" class="action-bar">
</ActionBar>
<ScrollView class="page">
<StackLayout class="home-panel">
<StackLayout *ngFor="let item of silabusList ; let i = index">
<Label [text]="item.subject" (tap)="btn(i)" ></Label>
</StackLayout>
</StackLayout>
</ScrollView>
Using ng-template
<ng-template ngFor let-item [ngForOf]="silabusList">
<Label [text]="item.subject"></Label >
</ng-template>
Comments
Post a Comment