Solved

angularjs pass parameter to controller via tag

Posted on 2014-02-19
1
1,009 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JQuery & Classic ASP 10 41
asp.net mvc5 6 34
Want my table columns to autofit. 7 63
Phone number mask 4 14
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

751 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