Solved

angularjs pass parameter to controller via tag

Posted on 2014-02-19
1
959 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 82

Accepted Solution

by:
leakim971 earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

912 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now