angularjs - how to link/add modal value with in existing json object in angular js -


below html:

<tr ng-repeat-start="select in selection">     <td style="overflow: hidden;">{{select.name}}</td>     <td style="overflow: hidden;">{{select.type}}</td>     <td style="overflow: hidden;">{{select.application}}</td>     <td>         <image ng-src="{{commentimg}}" width="20" height="20" ng-click="selectcomment()"></image>     </td> </tr> 

selectcomment opens modal has textarea. selection array has 3 key/value per object(i.e. name,type, application). want add textarea value fourth key/value in every object selection json object.

below modal:-

   <div class="dialog-panel3">     <div class="page-title">         comments     </div>     <br>     <form name="commentform">         <textarea class="textarea" ng-model="inputvalue" required></textarea>         <br>         <br>         <button ng-click="comment(inputvalue)" ng-disabled="commentform.$invalid">save</button>&nbsp;&nbsp         <button ng-click="close()">cancel</button>     </form>  </div> 

please suggest.

on click of image opens modal, can save corresponding index of json object. create ng-model textarea using index link value existing json array object.

html:

<tr ng-repeat-start="select in selection">     <td style="overflow: hidden;">{{select.name}}</td>     <td style="overflow: hidden;">{{select.type}}</td>     <td style="overflow: hidden;">{{select.application}}</td>     <td>         <image ng-src="{{commentimg}}" width="20" height="20" ng-click="selectcomment($index)"></image>     </td> </tr> 

contoller

$scope.selectcomment=function(index){   $scope.selection[index].textareaval="";   $scope.selectedindex=index; } 

modal:

<div class="dialog-panel3">     <div class="page-title">         comments     </div>     <br>     <form name="commentform">         <textarea class="textarea" ng-model="selection[selectedindex].textareaval" required></textarea>         <br>         <br>         <button ng-click="comment(selection[selectedindex].textareaval)" ng-disabled="commentform.$invalid">save</button>&nbsp;&nbsp         <button ng-click="close()">cancel</button>     </form>  </div> 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -