I have a form with fields which are disabled by default. User can only view the info in it unless they press the edit button. when they click the edit button the fields will be re enable the fields with some new styles(say a green border) i want to add a class to these field which i can style in my CSS. What is the Angular way to do it?
HTML
<form class="form-horizontal" role="form" ng-submit="edit_setting()" ng-controller="ExchangeController">
<div class="form-group">
<label>Name</label>
<div class="col-sm-6">
<input type="text" class="form-control" ng-model="name" ng-disabled="true">
</div>
</div>
<div class="form-group">
<label>Email</label>
<div class="col-sm-6">
<input type="email" class="form-control" ng-model="email" required ng-disabled="true">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-8 col-sm-6">
<button type="submit" class="btn btn-success">Edit</button>
</div>
</div>
</form>
Controller
function ExchangeController($scope) {
var details = "https://pvbp.com/api/settings.html?contactid=292351&exchange_id=7124&clearinghouseid=1&token=e5349652507c0esae86d50fdbdc53222cf97&page=view";
$http.get(details).success(function(response){
$scope.exchange_dt.exchange_name = response.name;
$scope.exchange_dt.exchange_host_name = response.email;
});
$scope.edit_exchange_setting_click = (function(){
// add new class for the fields here dynamically
});
}
ng-class
will not remove your existing class – Michael P. Mar 9 at 10:29