不能使用Angular.js动态启用文本字段
Can not enable text field dynamically using Angular.js
我有一个问题。我需要启用我的文本字段动态使用angular.js,但它没有发生。我在下面解释我的代码。
<tr ng-repeat="gl in galleryDatas">
<td><input type="checkbox" ng-change="clickedRow(gl.checked,$index)" name="" ng-model="gl.checked"> {{$index+1}}</td>
<td><img ng-src="upload/{{gl.image}}" border="0" name="image" style="width:100px; height:100px;" /></td>
<td><textarea id="address" name="desc" class="form-control oditek-form" placeholder="Add comment" rows="6" ng-model="gl.description" style="height:70px" ng-readonly="gl.galComnt"></textarea></td>
<td>
<a class="btn btn-xs btn-success" title="Edit" ng-click="editComment(gl.gallery_id,$index,gl.description)"><i class="fa fa-pencil-square-o fa-fw"></i>{{gl.galEDit}}</a>
</td>
</tr>
控制器端代码如下:
$http({
method:'POST',
url:"php/customerInfo.php",
data:imageData,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).then(function successCallback(response){
$scope.formDiv=false;
$scope.gallery=true;
$scope.galleryDatas=[];
for(var i=0;i<response.data.length;i++){
var data={'gallery_id':response.data[i]. gallery_id,'subcat_id':response.data[i].subcat_id,'image':response.data[i].image,'description':response.data[i].description,'galComnt':true,'galEDit':"Edit"};
$scope.galleryDatas.push(data);
}
}
在这里我需要,而用户将点击编辑按钮,各自的行描述字段将是可编辑的。我的代码如下:
$scope.editComment=function(galid,index,comnt){
if($scope.galleryDatas[index].galEDit=="Edit"){
$scope.galleryDatas[index].galEDit="Update";
$scope.galleryDatas[index].galComnt=false;
}
}
但是这里不起作用。在这里,我需要而用户将点击任何行编辑按钮,各自的行文本区域将是可编辑的。
你不应该玩index
,最终会混乱(甚至更多,当你使用更多的过滤器对ng-repeat
),而不是只是传递一个gl
对象到editComment
函数。无论你在对象中做了什么改变,都会反射到它的原始引用和视图中。
ng-click="editComment(gl)"
$scope.editComment=function(gl){
if(gl.galEDit=="Edit"){
gl.galEDit="Update";
gl.galComnt=false;
}
}
对clickedRow
函数执行相同的操作
相关文章:
- 使用javascript Without Ajax/Jquery在特定行中启用文本框
- 单击每个表格行中的复选框时启用文本框
- 禁用基于下拉列表选择 asp.net JavaScript 启用文本框
- 根据下拉列表中的选定值启用文本框
- 重新启用文本选择(Opera、webkit等)
- 根据输入启用文本框
- 通过JS功能在中继器中启用文本框
- 启用文本框选中复选框数组
- 如何在特定行中启用文本框
- 单选按钮未启用文本框
- 启用文本输入
- 与disableSelection功能相反,后者用于为特定HTML元素启用文本选择
- ASP.NET MVC Checboxes禁用/启用文本框
- 无法使用mootools启用文本框
- 当下拉框中的值被选中时,启用文本框
- 选中单选按钮导致在asp.net中启用文本框
- 如何在ChromeOS应用程序窗口中启用文本选择
- 禁用/启用文本框,单击单选按钮
- 使用javascript启用文本框
- 启用文本选择javascript