gpt4 book ai didi

javascript - 在 Angular JS 中重新启用 ng-disabled 按钮

转载 作者:太空狗 更新时间:2023-10-29 13:41:46 24 4
gpt4 key购买 nike

我是 AngularJS 的新手。我创建了一个表单,其中包含使用 ng-disabled 禁用的字段默认。当我点击编辑 <button>我希望重新启用这些字段。

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

});
}

最佳答案

在 Controller 中创建作用域变量,

$scope.disabled= true;

并用该变量替换所有 ng-disabled,例如,

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

当您单击编辑按钮时,将 $scope.disabled 设置为 false,例如,

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

关于javascript - 在 Angular JS 中重新启用 ng-disabled 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28936215/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com