Skip to content

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.

Properties

The Hero model is a POCO has 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.

Constructor

You can construct a new Hero model instance using the 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 pricture
  • profile - String containing a url to the user's profile page

Example

The following example implements a simple ng2 component using the Hero model to display the users name and email:

    import { Component } from '@angular/core';
    import { Hero } from 'ng2-app-scaffold';
    @Component({
        selector: 'app',
        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/'
        );
    }  
Clone this wiki locally