import { Component , Input , OnChanges , SimpleChanges , OnInit } from "@angular/core" ; import { ItemService , Item } from "../usage/usage.service" ; import { ItemEventData } from "@nativescript/core" ; @ Component ( { moduleId : module . id , templateUrl : "./tips-and-tricks.component.html" } ) export class ListViewTipsComponent implements OnInit { items : Array < Item > ; constructor ( private _itemService ) { } ngOnInit ( ) { this . items = this . _itemService . getItems ( ) ; } onItemTap ( args ) { console . log ( `Index: ${ args . index }; View: ${ args . view } ; Name: ${ this . items [ args . index ] . name }` ) ; } templateSelector ( item , index , items ) { return index % 2 === 0 ? "red" : "green" ; } } @ Component ( { selector : "sdk-child-component" , moduleId : module . id , template : `
        <StackLayout orientation="horizontal" class="list-group-item">
            <Label text="This is item with ID: " textWrap="true"></Label>
            <Label [text]="myData.id" textWrap="true"></Label>
        </StackLayout>
    ` } ) export class SdkChildComponent implements OnChanges { @ Input ( ) data : any ; public myData : any ; ngOnChanges ( changes ) { this . myData = changes [ "data" ] . currentValue ; } }