Add class to an element in Angular 4

前端 未结 5 1972
北荒
北荒 2021-02-01 14:28

I was trying to create an image gallery with Angular 4.The logic behind this is to add a Cascading Style Sheet (CSS) class to the selected image that will show a red border on t

5条回答
  •  佛祖请我去吃肉
    2021-02-01 15:04

    If you want to set only one specific class, you might write a TypeScript function returning a boolean to determine when the class should be appended.

    TypeScript

    function hideThumbnail():boolean{
        if (/* Your criteria here */)
            return true;
    }
    

    CSS:

    .request-card-hidden {
        display: none;
    }
    

    HTML:

    
    

提交回复
热议问题