Skip to content

Instantly share code, notes, and snippets.

@trumbitta
Last active May 19, 2017 17:48
Show Gist options
  • Select an option

  • Save trumbitta/9bacecdb13b1b22a8fa09ee276c7cf51 to your computer and use it in GitHub Desktop.

Select an option

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
<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>
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