Robert
Robert

Reputation: 2691

Angular 9 ng-if and ng-show - element is always displayed

In Angular 9 I have code in that I want to hide html element. In typescript I have public property:

export class UserPageComponent implements OnInit {
  public postModel: any = {};

And in Html component I want to check if I should display html element:

<mat-video ng-if="postModel.moviePath != ''" src="{{ postModel.moviePath }}"></mat-video>

But element mat-video is always displayed. When I wanted to use ng-show the result is the same.

Upvotes: 0

Views: 6240

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222522

You are using angularjs syntax, with angular it should be ngIf directive

<mat-video *ngIf="postModel.moviePath != ''" src="{{ postModel.moviePath }}"></mat-video>

Also there is NO ng-show with angular.

Upvotes: 1

Related Questions