If "myA.myB" is undefined or null, then "myA.myB[subscript]" will throw an exception. This is simple Javascript programming and not anything to do with Angular.
Although Angular *could* cover the possibility of referencing undefined variables or members in bound logic, doing so could hide bad code and produce unexpected results. It is up to you, as the programmer, to decide what happens when the variable/member you are referencing is not defined. I hope that explains things. On Tue, Jul 19, 2016 at 9:00 AM, p. stephen w <[email protected]> wrote: > You're not being helpful. Please try to understand the question before > posting. > > On Tuesday, July 19, 2016 at 5:51:56 AM UTC-7, Lucas Lacroix wrote: >> >> This is not Angular. This is just Javascript and you cannot get the >> member (or subscript) of something that is null or undefined. >> >> On Tue, Jul 19, 2016 at 8:42 AM, p. stephen w <[email protected]> >> wrote: >> >>> Ah, that does work, even on a deeper object: >>> *ngIf="myA.myB && myA.myB['1234']" >>> >>> But why does that work, but not this: >>> *ngIf="myA.myB['1234']" >>> >>> >>> >>> >>> On Tuesday, July 19, 2016 at 12:17:24 AM UTC-7, Sander Elias wrote: >>>> >>>> Hi P. Steven, >>>> >>>> You can use && to cater to your use-case. >>>> like: >>>> {{myBlah && myBlah['test']}} >>>> >>>> its much lighter as a pipe, and doesn't need to add the properties to >>>> your bare classes. >>>> >>>> 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. >>> >> >> >> >> -- >> Lucas Lacroix >> Computer Scientist >> System Technology Division, MEDITECH <http://ehr.meditech.com> >> 781-774-2293 >> > -- > 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. > -- Lucas Lacroix Computer Scientist System Technology Division, MEDITECH <http://ehr.meditech.com> 781-774-2293 -- 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.
