Matthew Garton
Posts: 0
Joined: Fri Jul 31, 2015 2:22 am

Selecting elements angular.js

Hi,
I have been trying to select elements in the init script of page that is using bootstrap angular.js and cannot figure it out via the documentation.

Ultimately I want to set the height of a button based on the screen size.

What I cannot do is be able to find or set the property value for the button because I can seem to get the button selected.

Everything I try just return reference not defined in the console of the browser and does not work.

I have tried the following three syntax and variations:

var x = appery('Button1').find(':selected').text(); (reference to appery not defined)
var x = apperyio('Button1').css('Height'); (reference to apperyio not defined)
var x = $( ".mainbtn" ).css('height'); (reference to $ not defined

I read this article:
https://devcenter.appery.io/documenta...

where you make this statement:
Note: It’s extremely important that you know how to select elements in the DOM using just the jQuery API.

So i have been googling that, looking at your tutorials and cannot figure this out.

Can you please help me. Image

Matthew Garton
Posts: 0
Joined: Fri Jul 31, 2015 2:22 am

Selecting elements angular.js

Some other code snippets I have tried

var x = Apperyio('Button1'); (TypeError: object is not a function)
var x = Apperyio('Button1').find(); (TypeError: object is not a function)

Pavel Zarudniy
Posts: 0
Joined: Mon Jul 06, 2015 8:56 am

Selecting elements angular.js

Hi Matthew,
For style manipulating you need to add ng-style attribute with some variable.
And than through this variable you can change style for element
Doc that can help - https://docs.angularjs.org/api/ng/dir...

Matthew Garton
Posts: 0
Joined: Fri Jul 31, 2015 2:22 am

Selecting elements angular.js

Hi,
Thanks for the response. For anyone out there that needs this it took me forever too works this out.

In the init function on the page I had this code:

$scope.btn_height = "{'height' : '" + window.innerHeight /2 + "px'}";

Then on the button in the design view. Add the attribute:
ng-style
Put in the value of:
{{btn_height}}

Kind Regards,
Mathew

Ankita Mehta
Posts: 0
Joined: Sun Apr 10, 2016 12:10 am

Selecting elements angular.js

Hi Matthew,

Thanks a lot for sharing this.
I'm facing this issue now and tried to do what you've suggested with dynamically changing the background-image for input checkbox. Is there anything else you did on top of what you've described?

Regards
Ankita

Return to “Issues”