Good afternoon, I have an error when connecting the service

angular.js:13236 Error: [jqLite:nosel] Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element http://errors.angularjs.org/1.5.0/jqLite/nosel at angular.js:68 at Object.JQLite [as element] (angular.js:2860) at Object.submit (former.js:56) at new <anonymous> (employeesimport.js:7) at Object.invoke (angular.js:4604) at extend.instance (angular.js:9855) at Object.link (angular-material.js:1540) at linkElement (angular-material.js:2926) at angular-material.js:2800 at processQueue (angular.js:15552) 

It swears (I think so) on this line here in former.js: 56

 var former = angular.element("#former");// <----------------- function submit(path, data, options) { options = options || {}; data = data || {}; var options = angular.extend(provider.options(),options); if(options.events.begin) { options.events.begin(data,options); } var url = provider.option('url') + path; var former = angular.element("#former"); var target = '_blank'; var userAgent = window.navigator.userAgent; var browsers = {chrome: /chrome/i, safari: /safari/i, firefox: /firefox/i, ie: /trident|msie|edge/i}; for(var key in browsers) { var search = browsers[key].test(userAgent); if (search == true && key == 'ie') target = '_self'; } if(!former.length) { former = angular.element("<form>",{ action: url, method: 'POST', target: target }); } angular.forEach(data,function(value,key) { if (value === Object(value)){ appendObject(former, key, value); }else{ former.append(angular.element("<input>",{ type: 'hidden', name: key, value: value })); } }); angular.element(document.body).append(former); former.submit(); former.remove(); } 

the link which is indicated in the error text http://errors.angularjs.org/1.5.0/jqLite/nosel did not find anything intelligible.

  • I recommend to translate the error message. It will immediately become clear why there is “nothing intelligible,” that is, there is no easy way to fix this, the link is gone. - D-side
  • Well, the translation is as follows: Looking for elements through selectors is not supported by jqLite! These types of elements are not supported by jqLite but nonsense, I "stole" this service from our other project where the full jQuery library was not connected - Igor Kalamurda
  • There it could work for other reasons that we will never know. But we know exactly why it does not work now. - D-side
  • I am not a colleague of Wang, of course, thanks for trying to push an idea, but I still do not understand what you are talking about - Igor Kalamurda
  • one
    There it is directly written that jqLite does not support any selectors harder than the tag name. No id , no classes, no attributes, no order, no links between elements, it does not understand. - D-side

1 answer 1

As stated in the error angular.element cannot search by the passed string, since this is just a lite version.

And in the help there is indicated that you can replace the search by string using the find method. But the easiest way is to use native type search tools: document.querySelector , document.getElementById and others, and transfer the results to angular.element .

In this case, document.getElementById enough.

 var former = angular.element(document.getElelementById("former"));