The error is occurring before the check for null on account_group_name; 
this error is saying that sub_group_id is null i.e the code is trying to do 
accountgroup[null].account_group_name.
Some values in the Object accountgroups are not formed as expected at the 
time of being retrieved. If these unformed values are not a problem you can 
use a catch on the object inside the *ngIf:

*ngIf="accountgroup.sub_group_id && 
accountgroup.sub_group_id.account_group_name === null ; else elseBlock"



On Thursday, February 15, 2018 at 6:18:16 AM UTC, Rakhee Menon wrote:
>
> Hi,
>
> I am displaying a list of accountgroup names..However I get this error..
> AccountGroupMasterListComponent.html:52 ERROR TypeError: Cannot read 
> property 'account_group_name' of null
>     at Object.eval [as updateDirectives] 
> (AccountGroupMasterListComponent.html:57)
>     at Object.debugUpdateDirectives [as updateDirectives] 
> (core.es5.js:13067)
>     at checkAndUpdateView (core.es5.js:12251)
>     at callViewAction (core.es5.js:12599)
>     at execEmbeddedViewsAction (core.es5.js:12557)
>
> Please check mycode.
>
> <tr *ngFor="let accountgroup of accountgroups ">
> <td>
> <!-- <a [routerLink]="['/accgrps',accgrp.id]"> -->
> <a [routerLink]="['/accgrps',accountgroup.id]">
>                {{ accountgroup.account_group_name }} 
>              </a>
> </td>
> <td>{{ accountgroup.base_group }}</td>
> <td *ngIf="accountgroup.sub_group_id.account_group_name === null; else 
> elseBlock">
> {{ null }}
> </td>
> <td><ng-template #elseBlock>
> {{ accountgroup.sub_group_id.account_group_name}}
> </ng-template>
> </td>
> </tr>
> please could anyone help me out..
> Thanks,
> Rakhee
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" 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.

Reply via email to