0

I'm setting a code to show image only if data there..i need to hide if value is undefined..help Here...

<div class="column" *ngIf="idvisaurl">
<img width="100" height="100" [src] ="idvisaurl"> 
<div><h5 style="font:bold">Visa Photo</h5></div>
7
  • 4
    i'm not getting result.? What does that mean? Post all the relevant code, tell precisely what you expect to happen and what happens instead. A complete minimal example posted as a stackblitz would help, too. Commented Jun 22, 2019 at 7:02
  • Are you sure the value of idvisaurl is undefined?? is not empty string or null or anything else?? add {{ idvisaurl }} in html to test it Commented Jun 22, 2019 at 7:03
  • if it was an empty string or null, it would still be falsy and the div wouldn't show. Commented Jun 22, 2019 at 7:04
  • 1
    Your html is incorrect, it's missing the closing div Commented Jun 22, 2019 at 7:07
  • ya sure.. value is undefined @moha noorani Commented Jun 22, 2019 at 7:12

1 Answer 1

1

Shared a reference code .... with dummy content

HTML:

<div  *ngIf="show != undefined">
   "CONTEMNTTT"
</div>

<div  *ngIf="notShow != undefined" >
   "CONTEMNTTT"
</div>

TS:

import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {

  show = "show";
  notShow
}

Stackblitz_Demo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.