Vivek Nuna
Vivek Nuna

Reputation: 1

Hidden not working with Array in Angular

I'm trying to hide an image using [hidden] attribute using an array element, but its giving template parse error.

<img id="ProfilePictureResize_{{i}}" [hidden]="!{{temporarySubCategoryImageShow[i]}}" src="{{temporarySubCategoryImageUrl[i]}}"/>

But when I try [hidden] with boolean variable it works fine.

<img id="ProfilePictureResize_{{i}}" [hidden]="!isPreviewImage" src="{{temporarySubCategoryImageUrl[i]}}"/>

TS File:

public temporarySubCategoryImageShow: string[] = [];
private isPreviewImage: boolean = false;

Error Screenshot:

enter image description here

Upvotes: 0

Views: 191

Answers (2)

bugs
bugs

Reputation: 15313

You have to remove the interpolation from the hidden attribute.

[hidden]="!temporarySubCategoryImageUrl[i]"

Upvotes: 1

Abel Valdez
Abel Valdez

Reputation: 2408

Remove the interpolation "{{}}" in [hidden] attribute

 [hidden]="!temporarySubCategoryImageShow[i]"

Upvotes: 2

Related Questions