Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does angular2 have ngCloak

Tags:

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.

Does Angular 2 have any such directive or functionality to prevent such raw(uncompiled) form display.

like image 700
refactor Avatar asked Sep 09 '16 10:09

refactor


People also ask

What is ng cloak?

Definition and Usage The ng-cloak directive prevents the document from showing unfinished AngularJS code while AngularJS is being loaded. AngularJS applications can make HTML documents flicker when the application is being loaded, showing the AngularJS code for a second, before all code are executed.

Which of the below is required with Ng include directive?

The ng-include directive includes HTML from an external file. The included content will be included as childnodes of the specified element. The value of the ng-include attribute can also be an expression, returning a filename. By default, the included file must be located on the same domain as the document.

What is Ng in angular?

The ng-app directive defines the root element of an AngularJS application. The ng-app directive will auto-bootstrap (automatically initialize) the application when a web page is loaded.


2 Answers

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> 
like image 115
Nikhil Shah Avatar answered Oct 11 '22 07:10

Nikhil Shah


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

like image 31
refactor Avatar answered Oct 11 '22 07:10

refactor