angular.element vs document.getElementById or jQuery selector with spin (busy) control

后端 未结 10 2468
感动是毒
感动是毒 2020-11-28 02:18

I\'m using the \"Angularised\" version of the Spin control, as documented here: http://blog.xvitcoder.com/adding-a-weel-progress-indicator-to-your-angularjs-application/

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 02:45

    You should read the angular element docs if you haven't yet, so you can understand what is supported by jqLite and what not -jqlite is a subset of jquery built into angular.

    Those selectors won't work with jqLite alone, since selectors by id are not supported.

      var target = angular.element('#appBusyIndicator');
      var target = angular.element('appBusyIndicator');
    

    So, either :

    • you use jqLite alone, more limited than jquery, but enough in most of the situations.
    • or you include the full jQuery lib in your app, and use it like normal jquery, in the places that you really need jquery.

    Edit: Note that jQuery should be loaded before angularJS in order to take precedence over jqLite:

    Real jQuery always takes precedence over jqLite, provided it was loaded before DOMContentLoaded event fired.

    Edit2: I missed the second part of the question before:

    The issue with , I think it is not an angular issue, it is the intended behaviour of the native html5 number element.

    It won't return a non-numeric value even if you try to retrieve it with jquery's .val() or with the raw .value attribute.

提交回复
热议问题