You didn't lose your id. It's a parameter of your edit state, isn't it? You
are passing this parameter with your ui-sref...

ui-sref="editPosition({id: positions._id})"


You can retrieve its id inside your edit state's controller and then use it
to call the server and do whatever you want to do then.

I assume your edit state is something like this:

$stateProvider
>     .state('editPosition', {
>         url: 'edit/:id',
>         templateUrl: 'edit.html',
>         controller: function($stateParams) {
>             console.info('here is your position id ', $stateParams.id);
>         }
>     });


 Does that work for you?

On Sun, Jul 19, 2015 at 12:04 AM, Leonan Luppi <[email protected]>
wrote:

> Yes what moment I'll do that?
>
> Because when i click to edit it redirects to edit page (i lost my id, here)
>
> Em sábado, 18 de julho de 2015 20:40:55 UTC-3, fasfsfgs escreveu:
>>
>> If I understand it correctly, you have the position id in your edit
>> route. With that, just ask the server for the position with that id. Does
>> that make sense?
>>
>> On Sat, Jul 18, 2015 at 8:26 PM, Leonan Luppi <[email protected]>
>> wrote:
>>
>>> I have a shref to my edit page, how can i get data ?
>>>
>>> Em sábado, 18 de julho de 2015 20:25:37 UTC-3, Leonan Luppi escreveu:
>>>>
>>>> Hey, Thanks for you reply.
>>>>
>>>> Yes, you right! it's a good practice get data from server. But how can
>>>> i do that?
>>>>
>>>> See my table:
>>>>
>>>> <table class="table table-hover">
>>>> <thead>
>>>> <tr>
>>>> <th>id</th>
>>>> <th>description</th>
>>>> <th>actions</th>
>>>> </tr>
>>>> </thead>
>>>> <tbody>
>>>> <tr ng-repeat="position in vm.positions">
>>>> <td>{{position._id}}</td>
>>>> <td>{{position.description}}</td>
>>>> <td>
>>>> <div class="btn-group" role="group" aria-label="">
>>>>   <a ui-sref="editPosition({id: positions._id})" class="btn
>>>> btn-default"><i class="glyphicon glyphicon-pencil"></i></a>
>>>>   <a ui-sref="home" class="btn btn-default"
>>>> ng-click="vm.remove(position._id)"><i class="glyphicon
>>>> glyphicon-trash"></i></a>
>>>> </div>
>>>> </td>
>>>> </tr>
>>>> </tbody>
>>>> </table>
>>>>
>>>>
>>>>
>>>> Em sábado, 18 de julho de 2015 20:09:40 UTC-3, fasfsfgs escreveu:
>>>>>
>>>>> Forgive me if I'm wrong but I think a good practice is to get this
>>>>> single item again from the server since this route could be accessed
>>>>> without going thru the list first.
>>>>>
>>>>> If you don't want to do that for whatever reason, you could make your
>>>>> edit route a child from your list route.
>>>>> Then they could share data between their controllers or using resolve
>>>>> in an abstract state on top of them.
>>>>> I actually had to do this once. Let me know if you need me to
>>>>> elaborate on this.
>>>>> (I'm assuming you are using ui-router. Not sure if it's possible to do
>>>>> this with angular's router.)
>>>>>
>>>>> It would be nice to see some more ideas from other users as well.
>>>>>
>>>>> On Sat, Jul 18, 2015 at 7:48 PM, Leonan Luppi <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> How can i get data from ng-model when i call new route.
>>>>>>
>>>>>> Example:
>>>>>>
>>>>>> I have a product CRUD (Create, read, update, delete) and two page,
>>>>>> one display <table> with datas and other to edit my single data (that 
>>>>>> I'll
>>>>>> select).
>>>>>>
>>>>>> On <table> tag, i have a route that redirect to edit page, how can i
>>>>>> get the row data and display in my edit page at inputs?
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "AngularJS" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> To post to this group, send email to [email protected].
>>>>>> Visit this group at http://groups.google.com/group/angular.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "AngularJS" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/angular.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to