我必须创建用户编辑产品详细信息的基本CRUD应用程序,但在我的情况下输入值已填充但编辑后的值,编辑后的值不显示在控制器中如何修复这个问题
//editProductDetail function for edit the product detail
$scope.editProductObj = [];
$scope.editProductDetail = function(productObject) {
$scope.editProductObj = productObject;
}
//call udpateProductDetailc function for update the detail
$scope.item = {};
$scope.getProductKey = [];
$scope.udpateProductDetail = function(index, productObject) {
var data = {
productId : $scope.item.pid,
productName : $scope.item.pname,
brandName : $scope.item.bname,
productPrice : Number($scope.item.price)
}
$scope.getProductKey = productObject.key;
var db = firebase.database();
var sellerProduct = db.ref("sellerProduct");
}
<div ng-repeat="list in productArray">
<a href="#" class="fa fa fa-group"
onclick="document.getElementById('editProduct').style.display='block'" ng-click="editProductDetail(list)">
</a>
<div>
<div class="w3-container">
<div class="col-sm-9">
<div class="w3-container">
<label>Enter Prduct Id</label>
<input type="text" name="text" ng-model="item.pid"
value="{{editProductObj.productId}}"><br>
<label>Enter Brand Name</label>
<input type="text" name="text" ng-model="item.bname"
value="{{editProductObj.brandName}}"><br>
<label>Enter Product Name</label>
<input type="text" name="text" ng-model="item.pname"
value="{{editProductObj.productName}}"><br>
<label>Enter Product Price</label>
<input type="text" name="text" ng-model="item.price"
value="{{editProductObj.productPrice}}"><br>
</div>
</div>
</div>
<div class="w3-btn w3-blue" ng-model="wholeItem"
ng-click="udpateProductDetail($index, editProductObj)">Udpate
</div>
?
答案 0 :(得分:1)
尝试初始化“$ scope.item”,如下所示:
$scope.item = {pid: "",bname:"",pname:"",price:""};
答案 1 :(得分:0)
更改内容时,input
中的更改内容为ng-model
。您无需使用value
(ng-value
)
所以你的HTML应该是这样的:
<div class="">
<div class="col-sm-9">
<div class="w3-container">
<label>Enter Prduct Id</label>
<input type="text" name="text" ng-model="item.pid"><br>
<label>Enter Brand Name</label>
<input type="text" name="text" ng-model="item.bname"><br>
<label>Enter Product Name</label>
<input type="text" name="text" ng-model="item.pname"><br>
<label>Enter Product Price</label>
<input type="text" name="text" ng-model="item.price"><br>
</div>
</div>
</div>