send data from table to another page into forms

60 views Asked by At

I have a table in "clients.html" that contains clients data,when I clic on one of those clients then the "create Document" I want to send the data of this clients to the new page "Doc.html",this is my code:

clients.html

<div class="btn-group" style="
        right: 5px;
    " ng-repeat="post in posts">
        <div class="btn btn-icon">

        <a ui-sref="app.deviscl({customerID:post.id})" data-toggle="tooltip" title="create Doc"><img src="img\facturejj.png"
          class="m-b-xs w-xs"> </a> 
        </div></div>

this is the routing:

.state('app.deviscl', {
                   url: '/devis/ajout/:customerID',
           templateUrl: 'tpl/deviscl.html',
           controller: 'editController'
              })

but in the clients.html the button create Doc appears many times,If I try to remove ng-repeat from the div of the button I can't get any result thanks a lot for help

1

There are 1 answers

1
Guinn On

Basicly with this code you are creating a button for every post in posts. I am guessing you want 1 button, but somehow that 1 button knows which post in posts is selected?

In that case you can create a form with a select dropdown, then they pick a 'post in posts' from the select and then submit the form, which links them to the create doc page with the right data?

UPDATE Example as requested:

<form>
  <table>
    <tr>
      <td>
         <select ng-model="postId" ng-options="post.id as post for post in posts"></select>
      </td>
    </tr>
    <tr>
      <td><input type="submit" ng-click="createDoc(postId) value="save" /></td>
    </tr>
  </table>
</form>

Ofcourse you can alter this simple form to be applicable for your own app. e.g add css or change some names etc.

and then in your controller:

$scope.createDoc = function(postId) {
    app.deviscl({customerID:postId});
}

and your routing remains the same.