-
Notifications
You must be signed in to change notification settings - Fork 1
Hero Model
Thor Schueler edited this page Mar 10, 2017
·
7 revisions
The Hero model implements the model for the Hero Component. An instance of the model is generated and delivered by the Hero Service.
The Hero model is a POCO with the following properties:
- Name - Gets the display name of the current user
- Picture - Gets the url for the user's picture
- Email - Gets the user's email address
- UserId - Gets the user's login id
- Profile - Gets the url for the user's profile page.
You can construct a new Hero model instance using its constructor:
constructor(
id: string,
name: string,
email: string,
picture: string,
profile: string)
Parameters:
- id - String containing the user's login id
- name - String containing the user's full name
- email - String containing the user's email address
- picture - String containing a url to the user's picture
- profile - String containing a url to the user's profile page
The following example implements a simple ng2 component using the Hero model to display the user's name and email:
import { Component } from '@angular/core';
import { Hero } from 'ng2-app-scaffold';
@Component({
selector: 'hero',
template: `
<div class="user">
<div><span class="label">Name: </span>{{hero.Name}}</div>
<div><span class="label">Name: </span>{{hero.Email}}</div>
</div>
`
})
export class User{
hero:Hero;
constructor(){
this.hero = new Hero(
'tschueler',
'Thor Schueler',
'[email protected]',
'https://media.licdn.com/media/AAEAAQAAAAAAAAT-AAAAJDdiZTQ3OTI3LTMzM2YtNDYzZi1iMzUxLTc5ZTY3NTY0OTFhNg.jpg',
'https://www.linkedin.com/in/thorschueler/'
);
}
}