Hi Timothy,
You can use the elvis operator as Günter mentioned. However I taste from
your question that you actually want to run some logic on the moment the
data comes in. For this you can use the ngOnChanges lifecycle hook.
something like this:
import {Component, Input} from 'angular2/core';
import {Transport} from "./models/Transport";
@Component({
selector: "child",
template: `<h2>In Child Component</h2>
<h3>Electric Cars</h3>
<br/>
This is not an ideal solution: <b>transport.cars[0].electrics[1].name</b>
yields:
<br/>
{{electricCar}}
`
})
export class ChildComponent {
@Input() transport: Transport;
ngOnChanges() {
this.electricCar=this.transport.cars[0].electrics[1].name;
}
}
Here I use a local variable to put the desired string in the view. If you
need to edit, make it a reference to an array or an object, otherwise your
changes will get lost.
Regards
Sander
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.