Currently, I am working on developing an application using Ionic and below is the code snippet:
<ion-header>
<ion-navbar>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Welcome</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<h3>Let's get started</h3>
<p>
Including some text here.
</p>
<ul>
<li> {{ Schueler.name }} </li>
</ul>
</ion-content>
The typescript definition for this code is as follows:
import { Component } from '@angular/core';
import { NavController , NavParams } from 'ionic-angular';
import { Student } from '../../app/student.components';
@Component({
selector: 'page-page1',
templateUrl: 'page1.html'
})
export class Page1 {
constructor(public navCtrl: NavController) {
var Schueler = new Student('Doldi');
console.log(Schueler.name)
}
}
While the instantiation of a new Schueler instance works perfectly fine and can be printed in the console without any issues.
However, I encountered an error message: "Error in ./Page1 class Page1 - caused by: Cannot read property 'name' of undefined" I assumed it would be feasible to access the Schueler instance within the HTML code.