Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

angularjs pass parameter to controller via tag

Posted on 2014-02-19
1
Medium Priority
?
1,066 Views
Last Modified: 2014-03-08
Hi,
I have an app and controller. I want to pass a variable through an html tag without using a directive or using init.  This is being added to existing code.  I can't change the line below.

I have the div below.  How can I read the height and width values?

<div data-ng-app="AngularApp" data-ng-controller="TestController" width = '100' height = '200' ></div>
0
Comment
Question by:jackjohnson44
1 Comment
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39873038
The best practice say : Don't do DOM manipulation inside controller, use a directive.
You don't want to use a directive so why are you using angular ?
Let say you can't really change the line, close your eyes and just use :

var ngAppEl = $("div[data-ng-app]");
var w = ngAppEl.attr("width");
var h = ngAppEl.attr("height");

Open in new window


Now pray that the police don't catch you :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question