0

I would like to know how to put an angularjs model as the value for an html attribute. such as:

<div ng-controller="deviceWidth" width={{width}}> </div>

also, how would I do this within <style> markup? Where would I put ng-controller?

div {
    width:{{width}}
}

Thanks, Ben

0

1 Answer 1

1

You'd better do create own custom directive instead of the "static" width, and interpret the interpolation with $observe function.

Post pretty similar, involving some solutions:
String Interpolation Won't Work when Setting Attribute Values on a Custom Directive

Concerning the markup, you'd better play with ng-class, whose value comes from your controller logic.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.