Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
35
rated 0 times [  38] [ 3]  / answers: 1 / hits: 30153  / 9 Years ago, mon, march 9, 2015, 12:00:00

I am a newbie to AngularJS. I have created a form with fields which is disabled using ng-disabled by default. when I click on the edit <button> I want these fields to re-enable.



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=exchange_dt.name ng-disabled=true>
</div>
</div>
<div class=form-group>
<label>Host Name</label>
<div class=col-sm-6>
<input type=text class=form-control ng-model=exchange_dt.host_name required ng-disabled=true>
</div>
</div>
<div class=form-group>
<label>Address</label>
<div class=col-sm-6>
<input type=text class=form-control ng-model=exchange_dt.address ng-disabled=true>
</div>
</div>
</form>


Controller



  function ExchangeController($scope, $http, $cookieStore, $location) {
var edit_exchange_setting = https://pvbp.com/api/settings.html?contactid=292351&exchange_id=7124&clearinghouseid=1&token=e5349652507c0esae86d50fdbdc53222cf97&page=view;
$http.get(edit_exchange_setting).success(function(response){
$scope.exchange_dt.exchange_name = response.name;
$scope.exchange_dt.exchange_host_name = response.host_name;
$scope.exchange_dt.exchange_last_processed_date = response.address;
});

$scope.edit_exchange_setting_click = (function(){
// how can i make the fields re enable here

});
}

More From » jquery

 Answers
2

in controller create scope variable,



$scope.disabled= true;


and replace all ng-disabled with that variable like,



...ng-model=exchange_dt.name ng-disabled=disabled....


when you click on edit button set $scope.disabled to false like,



$scope.edit_exchange_setting_click = (function(){      
$scope.disabled = false;
});

[#67518] Friday, March 6, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alli

Total Points: 409
Total Questions: 101
Total Answers: 105

Location: The Bahamas
Member since Tue, Apr 27, 2021
3 Years ago
alli questions
Sat, Apr 23, 22, 00:00, 2 Years ago
Mon, May 18, 20, 00:00, 4 Years ago
Tue, Mar 24, 20, 00:00, 4 Years ago
Fri, Jan 24, 20, 00:00, 4 Years ago
;