-2

I have this case in which I want to check against a string that contains curly braces. Data retrieved from object contains a string with curly braces.

             let defaultTitleFromComponentVar = 'Hello There';
             let dataList = ['Test1', 'Title2', '{{defaultTitle}}', 'Title3'];

             <ul>
                <li *ngFor="let title of dataList">
                  <ng-container *ngIf="title == '{{defaultTitle}}'">
                    {{ defaultTitleFromComponentVar }}
                  </ng-container>
                  <ng-container *ngIf="title != '{{defaultTitle}}'">
                    {{ title }}
                  </ng-container>  
                </li>
              </ul>

Error get in console:

Uncaught Error: Template parse errors: Can't bind to '*ngIf' since it 
isn't a known property of...
Uttam Panara
  • 541
  • 2
  • 10
  • 28

2 Answers2

1

You need to escape every curly brace using \

*ngIf="title == '\{\{defaultTitle\}\}'

Luis Rico
  • 625
  • 6
  • 22
0

maybe simply

*ngIf="title == '{{custTitle}\}'"
Andrey
  • 1,752
  • 18
  • 17