Muirik
Muirik

Reputation: 6289

Evaluation on-the-fly in String Interpolated Value in Angular 2 App

I am trying to use an *ngIf in my Angular 2 app, and have it evaluate whether a string interpolated value is set to a certain parameter. I've tried several syntactical constructions, but so far they all return errors. I've tried, for instance, something like this:

<div *ngIf="{{info.status === 'consult'}}">

I've also tried:

<div *ngIf="[{{info.status === 'consult'}}]">

And...

<div *ngIf="{{info.status}} === 'consult'">

What is the correct way to pass in this string interpolated value and have it evaluated on the fly?

Upvotes: 1

Views: 166

Answers (1)

Eddie Martinez
Eddie Martinez

Reputation: 13910

When you are inside an Angular2 directive you do not need to put the interpolation syntax. Do this

<div *ngIf="info?.status === 'consult'">

Upvotes: 2

Related Questions