ANGULARJS Advanced Gameplay Create a recursive template compatible with IE browser

Source: Internet
Author: User

When it comes to compatible IE7 IE8 browsers, Angularjs has made it clear that the v1.3 version (including v1.3) will not support IE7 IE8, so if you want to be compatible with IE7 IE8 You must use the following version of v1.3


The previous article on the recursive play, but IE7 IE8 is not play, the principle of my simple explanation,

Angularjs in the loading of a template, will parse the content, the content into element (elements or nodes), here is the problem, in ie9+, chrome these browsers, will <script> This tag is also treated as an element, but not in IE7 IE8, so when the template is loaded, Angularjs does not put the script content in the $templatecache cache, and Ng-include is actually in the $ Templatecache the template in the cache, so ng-include does not take the contents of the script, resulting in IE7 IE8 does not show the results we want


Workaround:

Now that the problem is known, we just need to insert a recursive code into $templatecache before Ng-include gets $templatecache's script, which solves the

$templateCache There are two ways we can use, get and put,

$templateCache. Get (Key)

$templateCache. Put (key, value)

We can call the $templatecache.put method in the controller, the original script ID as the contents of the key,script inside as value, passed to $templatecache that can be realized the original recursive function

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

ANGULARJS Advanced Gameplay Create a recursive template compatible with IE browser

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.