Angularjsng-optionieissue Solution

Source: Internet
Author: User
Recently, angularjs used ng-options as the select option data source in IE and was nested in ng-switch (ng-transclude) and the like, after the ng-options data source model changes on angular, It is not rendered on IE. After a while of testing and reading the relevant documentation... syn recently met angularjs using ng-options as the select option data source in IE, and is nested in ng-switch (ng-transclude) and the like, after the ng-options data source model changes on angular, It is not rendered on IE. After a while of testing and reading the relevant documentation, I finally confirmed that: Because ng-switch (ng-transclude) is used to make its scope the original parent scope, after DOM is generated on the parent scope, cloneNode is cloned to the specified instruction location. However, IE does not trigger re-painting for the nodes cloned by the select statement, so the above issue is available. The problem is fixed, so what we need to do is to manually trigger IE to re-paint the Select statement. After trying a lot of methods, we finally confirm that it is effective: first, add an option with native js on options and immediately remove this option. The solution is as follows: allow. module ('ie. select ', []). directive ('aeselectfix', [function () {return {restrict: 'A', require: 'select', link: function (scope, element, attributes) {var isIE = document. attachEvent; if (! IsIE) return; var control = element [0]; scope. $ watch (attributes. ieSelectFix, function () {// it shoshould be use javascript way, not jquery way. var option = document. createElement ("option"); control. add (option, null); control. remove (control. options. length-1) ;}}}}]); usage: Select   

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.