Angularjs Page Load Flicker Solution

Source: Internet
Author: User

Angularjs This big kill device makes the implementation of the SPA (single page App) become unusually simple, its two-way binding so that the page content re-rendering without writing a large number of JS code, not to construct a DOM string ugly, as the need to quickly iterate, improve the user embodies the next generation of Internet applications, Angularjs can be said to have become one of the required technologies.

However, Angularjs also has a common problem with JavaScript, where the tag placeholder needs to trigger binding and rendering after the DOM is loaded and the JavaScript is loaded, which results in flashing when the page loads (the label is displayed before it is rendered out). Especially when the network speed is not ideal, seriously affect the user experience.

ANGULARJS provides two options to solve this problem:
1. Using the Ng-bind or Ng-bing-template property instead of the {{field}} placeholder, the default white space is displayed when initializing because the DOM property is not visible.
2. Use the Ng-cloak property or set the Ng-cloak style. The principle is that Angularjs adds a ng-cloak style to the head at initialization, which sets the display:none of the DOM, which is not displayed by default.

However, none of the two scenarios are ideal ng-bind or ng-bing-template cannot implement complex content representations, and modern browsers may still display the page before the Ng-cloak style is inserted into the head.

Final scenario: Add a Ng-cloak to the style sheet that is consistent with angularjs dynamic creation and statically loaded in the head

Angularjs Page Load Flicker Solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.