12 jqLite

Angular's jqLite

jqLite is a tiny, API-compatible subset of jQuery that allows Angular to manipulate the DOM in a cross-browser compatible manner. jqLite implements only the most common functions required.

jqLite method

jqLite only provides the following jQuery methods:

  • addClass()
  • after()
  • append()
  • attr()
  • bind() - does not support namespaces, selectors or eventData
  • children() - selectors are not supported
  • clone()
  • contents()
  • css()
  • data()
  • empty()
  • eq()
  • find() - only finds by tag name
  • hasClass()
  • html()
  • next() - selectors are not supported
  • on() - does not support namespaces, selectors or eventData
  • off() - namespaces, selectors are not supported
  • one() - namespaces, selectors are not supported
  • parent() - selectors are not supported
  • prepend()
  • prop()
  • ready()
  • remove()
  • removeAttr()
  • removeClass()
  • removeData()
  • replaceWith()
  • text()
  • toggleClass()
  • triggerHandler() - pass a dummy event object to handlers
  • unbind() - namespaces are not supported
  • val()
  • wrap()

jQuery/jqLite extension

Angular provides the following additional methods and events to both jQuery and jqLite:

event

  • $destroy - AngularJS intercepts all jqLite/jQuery DOM destruction apis and fires this event when all DOM nodes are removed. This can be used to clean up any third-party content bound to the DOM element before it is removed.

method

  • controller(name) - Gets the controller of the current element or its parent. The default fetched controller is related to the ngController directive. If name is a camel-cased directive name, the directive's controller will be retrieved (eg 'ngModel').
  • injector() - Get the injection of the current element or its parent.
  • scope() - Get the scope of the current element or its parent.
  • isolateScope() - Gets an independent scope attached directly to the current element. This getter can only be used on elements that contain instructions to start a new independent field. Calling scope() on this element always returns the original dependent scope.
  • inheritedData() - same as data(), but traverses the DOM until a value is found or the topmost parent element is reached.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325392384&siteId=291194637