How to access AngularJS {{curly-brace-value}} in jQuery

614
November 23, 2016, at 9:35 PM

From the question itself, I am sure you understand that I am not an angular/jquery expert.

I have a div generated using angular which looks like this:

<div id='my-div' style={{ang.style}}'>
This is content inside the div
</div>

As you can see the style for the div comes from angular. Is there any way I can get this value in jQuery?

If I do $('#my-div').attr("style") it just prints {{ang.style}}

I know this is not the right way to do it, but currently due to many constraints, I need to be able to get this value in jQuery at least as a temporary fix.

I hope the Angular/JQuery Gurus here will be able to help me...

Answer 1

You should use .css() instead of .attr("style") in jQuery to get the computed property.

Rent Charter Buses Company
READ ALSO
jQuery add target = _blank to all links that have a specific class

jQuery add target = _blank to all links that have a specific class

I am trying to add attribute target =_blank to all links that have specific classes. Example:.

566
Closing conditionally a bootstrap modal panel if login is succesful

Closing conditionally a bootstrap modal panel if login is succesful

I'm building a SPA webapp integrating reactjs with jquery, I have a component to control the authentication. It is rendering a modal panel with username and password.

532
Disabling Sunday from Datepicker

Disabling Sunday from Datepicker

I am trying to disable "Sunday" from being selected in the "datepicker" in our online booking script. I have searched on Google with hundreds of solutions, but none seem to take effect within the script when implemented.

452
Trying to open div [ordered] based on match to button order (Similar to Accordion)

Trying to open div [ordered] based on match to button order (Similar to Accordion)

I'm trying to create an experience on my personal site that allows users to click on a hero image of my work and watch a div open above the work in order to see more in depth info. .

626