Search code examples
nativescriptangular2-templateangular2-nativescriptangular-ng-if

Is there an analogue of "ngIf" directive in NativeScript without Angular?


In Angular, we can use *ngIf directive in the template in case if we want to create/remove (also show/hide) dom element.

Is there an analog of "ngIf" directive in NativeScript without Angular?


Solution

  • NativeScript supports the "collapsed" and "visible" states of the CSS visibility property. This means you can hide an element by setting its "visibility" property to "collapsed" in CSS.

    And you can conditionally change its property which will be (near about) same as angular's ngIf condition.

       visibility="{{ showTextDetails ? 'visible' : 'collapsed' }}"
    

    Hope this help!