我有一個問題。我需要啓用我的文本字段動態使用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;
}
}
但是這裏它不工作。在這裏,我需要用戶將點擊任何行編輯按鈕,相應的行文本區域將可編輯。請幫助我。
你可能會得到另一個錯誤,否則你的代碼應該工作:)。請參閱控制檯日誌 –
我沒有在控制檯中收到任何錯誤。 – subhra
我已經在plunker中用演示數據檢查過你的代碼。那是工作正常 –