Solved

angularjs pass parameter to controller via tag

Posted on 2014-02-19
1
943 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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

763 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

6 Experts available now in Live!

Get 1:1 Help Now