Does angular2 have ngCloak

后端 未结 3 370
名媛妹妹
名媛妹妹 2021-01-03 23:32

AngularJS 1.x has ngCloak directive, which is used to prevent the Angular html template from being briefly displayed by the browser in its raw (uncompiled) form.

Doe

相关标签:
3条回答
  • 2021-01-04 00:09

    Angular2 desn' have ngCloak,

    instead you can use ?. operator (use it with object).

    {{user?.name}}
    

    AND/OR

    you can use *ngIf (as of now)

    <div *ngIf="name"> {{name}}</div>
    
    0 讨论(0)
  • 2021-01-04 00:09

    You can prevent rendering of html by using *ngIf until the corresponding object is loaded:

    <div *ngIf="dataList">
    <>....</>
    </div>
    
    0 讨论(0)
  • 2021-01-04 00:11

    There are two types of compilations in Angular2 ,Just-in-Time(JiT) and Ahead-of-Time(AoT). Just-in-Time is the default compilation.

    JiT compilation incurs a runtime performance penalty.Views take longer to render because of the in-browser compilation step. The application is bigger because it includes the Angular compiler and a lot of library code that the application won't actually need. Bigger apps take longer to transmit and are slower to load.

    With AoT, the browser downloads a pre-compiled version of the application. The browser loads executable code so it can render the application immediately, without waiting to compile the app first.

    If we go with Ahead-of-Time compilation instead of Just-in-Time compilation, we can prevent such raw(uncompiled) form of display.

    This link provides more information

    0 讨论(0)
提交回复
热议问题