[Newbie] Variables


#1

let say i want to display a string in page.html:
<h1>{{stringvariable}}</h1>

-> what is the correct way to declare the stringvariable in page.ts ?
thx


#2

let stringvariable …


#3

Wrong. Template expressions can only access controller object properties, not lexical variables. To OP: RTFM.


#4

Wrong way? because it’s working fine…


#5

question: string;

constructor() {
this.question= ‘What do you wish?’;
}

is working, but how can I handle array-variables like:

questionarray = ["1","What do you wish?", "A", "B", "C"];
question=this.questionarray[1];

in a correct way? thx


#6

It’s really worth going through the whole Tour of Heroes. This topic is covered in chapter 2.


#7

will do that, thx! :slight_smile: