0

I am confused about angularjs manipulation.

How come:

   angular.element("#elementID").is(':visible') ;   // works
   angular.element("#elementID").slideUp() ;   // works
   angular.element("#elementID").style.opacity = 1 ; // **doesn't work**

   angular.element("#elementID")[0].style.opacity = 1 ;   // works
   angular.element("#elementID").css('opacity' : 1) ;   // **doesn't work**

I have a Cordova/Ionic app, jquery is installed. I feel the .css(field : value) should be working.

The various methods keep tripping me up. Can someone shed some light on this for me?

4
  • Does angular.element return a jQuery object prototype, or is it an Angular-specific flavor? Nevermind, I answered my own question, it does. Please make sure Angular can see jQuery, because "jqLite is a tiny, API-compatible subset of jQuery". This means that it is not a fully-featured replacement for jQuery. I suspect jQuery is not actually available to your Angular application. Commented Aug 29, 2023 at 19:32
  • Also, I believe the 3rd line should be: angular.element("#elementID").get(0).style.opacity = 1 This is because jQuery does not have access to the style property of the raw element. Commented Aug 29, 2023 at 19:37
  • AFIK get() isn't a function of angluarJS. According to the documentation docs.angularjs.org/api/ng/function/angular.element - css() should be working...but also is, `slideUp()' work but are not defined here either. Makes me wonder if Ionic extended it. Commented Aug 29, 2023 at 19:40
  • $.fn.get is a function in jQuery. It unwraps the native Element. The actual DOM element has a style property, not the jQuery object. Commented Aug 30, 2023 at 12:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.