javascript - How to edit and update according to user's choice in angularjs -


im trying edit selected item main view list in separate html view, when save button clicked changes reflected list in main view.im edit have used title,description,from , to dates edit.i got struck idea here, is, if user wants edit 1 of 4 details , save rest details same, tried ng-model read edited details not existing one. i'm looking in this.

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> 

controller:

   $scope.items = [];   $rootscope.couponlist = [{ title: "fruit export details" data: {description: "consume product", fromdate: "2016-09-09", todate: "2016-09-18"}},   {title: "vegetables export details",  data:{description: "consume 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');     } 

i think problem mismatching of ng-model names in controller

html (modified)

 <div align="center">                 title <!-- <input type="text" ng-model="selectinput.title"> -->                 <input type="text" ng-model="$scope.selectinput.data.title">                 offer:                 <input type="text" ng-model="$scope.selectedinput.data.description">                 valid from: <!-- <input type="date" ng-click="fromdate()" ng-model="frdate">-->                 <input type="date" ng-click="fromdate()" ng-model="$scope.selectinput.data.fromdate">                 <br> valid till: <!-- <input type="date" ng-click="todate()" ng-model="todate" /> -->                 <input type="date" ng-click="todate()" ng-model="$scope.selectinput.data.todate" />             </div>             <hr>             <button ng-click='saveedit($index)' ng-model="editsave"> save</button> 

js

$scope.items = [];   $rootscope.couponlist = [{ title: "fruit export details" data: {description: "consume product", fromdate: "2016-09-09", todate: "2016-09-18"}},   {title: "vegetables export details",  data:{description: "consume 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');     } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -