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
- 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');
ng-styleorng-classattribute that references some value from the model and update the model when you want to change the style/class.