Easy data binding questions


#1

I’m trying to display a bunch of information stored in an array which is posted to the view.

This code sends the data object variable to the view when the user has clicked a button.

this.zone.run(() => {
            this.place = place;
        });

I have tried to bind {{ place.user_id }} but it returns:

EXCEPTION: Error in ./HomePage class HomePage - inline template:8:35 caused by: undefined is not an object (evaluating 'self.context.place.user_id')

Here’s what the object looks like:

Place is only instantiated after the user clicks a button on the home page


#2

That’s the problem. You can either modify the template to be able to deal with place being empty or initialize place to something in the constructor.


#4

Thanks. All sorted. Initialised a blank ‘place’ object in the constructor.