How do I edit the width of a class using Angularjs?

Asked

Viewed 88 times

2

I have an element with two classes:

 <div class="classe1 classe2">

 </div>

I want to increase the width of my class 2 style, what would be the right way to do this?

  • Wants to edit the width of the class or the div? If it is of div it would be simpler to edit the style. If you want to change the width class even to affect all elements, maybe the best is to do override class.

2 answers

4


one of the correct ways to do this is to give the correct width to a new class, widthClass (for example) and then make a ng-class.

widthClass { width: 9000px }

<div ng-class="'widthClass': scope.needsMoreWidth" class="class1 class2"></div>

In your controller you’ll have something like:

$scope.needsMoreWidth = true;

2

If you want to apply width to all elements that apply class, in the case "classe2", at runtime, you can apply.

angular.element(".class2").width(500)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.