Created
April 4, 2019 09:31
-
-
Save Manbearpixel/2b288b3f2e456611b00d4ea483eb957d to your computer and use it in GitHub Desktop.
RadListView--Example--MultipleTemplates--Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
class User { | |
// These properties are publicly exposed | |
public name: string; | |
public status: string; | |
// Accept an optional name and status when being instantiated | |
constructor(name?: string, status?: string) { | |
this.name = name ? name : 'Default Name'; | |
this.status = status ? status : ''; | |
} | |
} | |
@Component({ | |
moduleId: module.id, | |
selector: 'example', | |
templateUrl: './radlistview-multipletemplates.html', | |
styleUrls: [] | |
}) | |
export class RadListViewMultipleTemplatesComponent { | |
// Define the array of Users which should be publicly exposed | |
public userCollection: User[]; | |
constructor() { | |
this.userCollection = [ | |
new User('The Boss', 'admin'), | |
new User('The User', 'basic'), | |
new User('The Unknown') | |
]; | |
} | |
/** | |
* Template rendering method to help determine which template to load for a given | |
* `User`. | |
* | |
* @param item The `User` model | |
* @param index The index of the item | |
* @param items The array of items | |
*/ | |
public userCollectionTemplateSwitch(item: User, index: number, items: any): string { | |
return item.status; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment