Reputation:
I want to add one width property to my text by selecting the class name.
$('input.select2-input').css('width', '330px');
Pure angularjs way to do this. Thanks
Upvotes: 0
Views: 547
Reputation: 1444
- HTML :
<div ng-style="{ 'width' : width }"></div>
- In your controller :
$scope.width = "330px";
- HTML :
<div ng-class="{myStyle : myExpression}"></div>
- CSS :
.myStyle {
width : 330px;
}
- In your controller :
$scope.myExpression = true;
Angular itself provide JQlite for basic Jquery needs, but for having your code clear, logic, editable this way is really not recommended :
var element = angular.element( document.querySelector('input.select2-input') );
element.css('width', '330px');
Upvotes: 1
Reputation: 88
In manipulating the DOM use a directive, in the link function. You can inject $document
or just get the element in the link function then add css styles.
Upvotes: 0