Reputation: 20875
I use a long expression twice within a single element in an Angular 2 view:
<a *ngIf="row.getEmployer()[i]!.getProfileLink()"
class="x-view-link"
href="{{ row.getEmployer().getEmployee()[i]!.getProfileLink() }}">
xv
</a>
Could I somehow store row.getEmployer().getEmployee()[i]!.getProfileLink()
inside a variable (called say link
, ie let link = row.getEmployer().getEmployee()[i]!.getProfileLink()
) within the view and then reuse that variable?
Upvotes: 0
Views: 23
Reputation:
You can because you use a condition.
Try that :
<a *ngIf="row.getEmployer()[i]!.getProfileLink() as link"
Link will now contain the result of your variable.
Upvotes: 1