Can I use ngIf in the modal box in angular2?

this is the code:

      <div class="col-7">
        <label>:</label>
        <input type="number" class="form-control" placeholder="" (keyup)="inputCoinQty()" required [min]="0.001">
      </div>
      <div *ngIf="inputCoinQty()" class="text-center">
        <p class="my-3">:{{values}}

<img src="/assets/images/pay.png" class="avatar-xxl"> <p class="my-3">

</div>

what you want to achieve: display the class text-center when the user types
this is in the modal of angular2, not in component
clipboard.png


turns out to be an expression, not a method, in * ngif.


* ngif can also be a method. The method has the return value of boolen. You can try it.


* ngIf= "expression" is followed by an expression, which means you can write methods, such as * ngIf=someFunc () . As long as the return value of someFunc () in Component can be displayed / implicitly converted to a value of type boolean.


you can listen to the change event of input, control the flage, in the change event, and then that div can use ngClass

ngClass the first parameter is the class name, the second parameter is the Boolean value, if it is true, add the class of the first parameter

when the user has input, flag is true. False

if the value is cleared
<div [ngClass]="{'text-center':flag}"><div>
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea603a-1da5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea603a-1da5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?