Hi Sander, Thanks for the tip! I can't use that with the [(ngModel)] syntax as I get the following error:
Bindings cannot contain assignments Which makes sense. But I can use the following syntax, to split out the get and set methods, and then it works: [ngModel]="job && job.name" (ngModelChange)="job.name = $event" Not the most elegant, but at least it works. The other alternative is I can initialise all the properties in my component which is maybe a bit cleaner but requires me to keep track of the properties of my job model which is slightly annoying.. Unless theres a way to create a typescript object and initialise everything to a default value automatically based on the interface? Thanks for your help, Mike On Tue, Jul 19, 2016 at 12:29 AM, Sander Elias <[email protected]> wrote: > Hi Michael, > > use the && to neglect the assignment until a value is actually in. > > looks a bit like: > {{ job && job.name = $event }} > > > I think this might work in your case. > > Regards > Sander > > -- > You received this message because you are subscribed to a topic in the > Google Groups "AngularJS" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/angular/TIwT89zH2-w/unsubscribe. > To unsubscribe from this group and all its topics, 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. > -- 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.
