Last active
May 19, 2017 17:48
-
-
Save trumbitta/9bacecdb13b1b22a8fa09ee276c7cf51 to your computer and use it in GitHub Desktop.
Something I've been doing several times a day with Angular and ngOnInit() since September 2016
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
| <ion-header> | |
| <ion-navbar> | |
| <ion-title> | |
| My App | |
| </ion-title> | |
| </ion-navbar> | |
| </ion-header> | |
| <ion-content padding> | |
| Ok: {{ userFirstName }} <!-- Pluto --> | |
| Ok: {{ user | json }} <!-- { firstname: "Pippo" } --> | |
| Error: {{ user.firstname }}! <!-- ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'firstname' of undefined | |
| TypeError: Cannot read property 'firstname' of undefined --> | |
| </ion-content> |
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'; | |
| @Component({ | |
| selector: 'wn-page-home', | |
| templateUrl: 'home.html' | |
| }) | |
| export class HomePageComponent { | |
| user: any; | |
| userFirstName: string; | |
| constructor() { | |
| // | |
| } | |
| ionViewWillEnter() { | |
| this.userFirstName = 'Pluto'; | |
| this.user = { firstname: 'Pippo' }; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment