Last active
October 10, 2016 09:26
-
-
Save andreisebastianc/87f0cf0e8ed095a1e891d7335630081f to your computer and use it in GitHub Desktop.
Some angular2 dummy component
This file contains hidden or 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"; | |
| interface User { | |
| name: string; | |
| image: string; | |
| fullname: string; | |
| } | |
| @Component({ | |
| selector: 'app', | |
| template: ` | |
| <div class="app-wrapper">Hi, I'm working!</div> | |
| <user-profile [profile]="user"></user-profile> | |
| ` | |
| }) | |
| export class App { | |
| user: User | |
| constructor() { | |
| this.user = { | |
| name:"test", | |
| image:"/public/default-user-profile.jpg", | |
| fullname: "test test test" | |
| }; | |
| } | |
| } |
This file contains hidden or 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, | |
| Input | |
| } from '@angular/core'; | |
| interface Profile { | |
| name: string; | |
| image: string; | |
| } | |
| @Component({ | |
| selector: 'user-profile', | |
| template: ` | |
| <div *ngIf="profile"> | |
| <div class="profile"> | |
| <img | |
| class="profile-image" | |
| src={{profile.image}} | |
| /> | |
| <span class="profile-name">{{profile.name}}</span> | |
| </div> | |
| </div> | |
| ` | |
| }) | |
| export class UserProfileComponent { | |
| @Input() profile: Profile; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment