我試圖在單獨的html視圖中編輯main view
列表中的所選項目,因此單擊save button
時,更改將反映到main view
中的列表中。我的我的編輯我已經使用title
,description
,from
和to
日期編輯。我在這裏碰到一個想法,那就是,如果用戶只想編輯四個細節中的任何一個並保存其餘細節相同,我試過了它與ng-model
,但它只能讀取編輯的細節,但不能讀取已經存在的細節。所以我正在尋找這方面的幫助。如何在angularjs中根據用戶的選擇進行編輯和更新
HTML:
<div align="center">
Title
<input type="text" ng-model="selectInput.Title">
Offer:
<input type="text" ng-model="selectInput.data.description">
Valid from:
<input type="date" ng-click="FromDate()" ng-model="frDate">
<br> Valid till:
<input type="date" ng-click="ToDate()" ng-model="toDate" />
</div>
<hr>
<button ng-click='SaveEdit($index)' ng-model="editSave"> Save</button>
控制器:
$scope.items = [];
$rootScope.couponList = [{ Title: "Fruit Export Details" data: {description: "consume soon product", Fromdate: "2016-09-09", Todate: "2016-09-18"}},
{Title: "Vegetables Export Details", data:{description: "consume soon product", Fromldate: "2016-11-09", Todate: "2016-10-19"}},
{ CouponTitle: "Saviours",data:{description: "storable", Fromldate: "2016-09-10", Todate: "2016-10-09"}}];
$scope.select_item = function (key) {
//alert(key);
$scope.items.push(key);
}
$scope.SaveEdit=function(){
$scope.Title=$scope.selectInput.data.Title;
$scope.description=$scope.selectedInput.data.description;
$scope.Fromdate=$scope.selectInput.data.Fromdate;
$scope.Todate=$scope.selectInput.data.Todate;
}
$state.go('app.WashType');
}