Hello,

I have a list of contacts on page 'contacts' and I want to edit a contact I 
clicked there on page contactDetails. To do that, I need to retrieve the 
contactId that was sent on page contacts 
as an argument to the clickhandler. But I am unable to access that data 
across after the router switched views.

Below is my setup. Note: this all happens in 1 (one) controller

router:

.config(["$routeProvider", function($routeProvider,$location){
    $routeProvider
        .when("/contacts", {        templateUrl:    
"/partials/contacts/contacts.htm",        controller:    
"contactController" })
        .when("/contactDetail", {    templateUrl:    
"/partials/contacts/contactDetail.htm",    controller:    
"contactController" }) <=== NOTE the same controller for 2 views!!
         .otherwise({redirectTo: "/contacts"})
      }]
 )

On page /contacts I display a list of contacts. When I click a contact I 
call a handler to show a detailpage:

<button ng-click="editContact(id)">Edit</button>

editContact(id) gets the value for id and switches to a new page:

$scope.editContact = function(contactId){
            $scope.contactToEdit = contactId;
            $location.path("contactDetail");
        }

This is where things go wrong. On the new page I want to access 
$scope.contactToEdit but it is unknown there. The filds that should display 
data from the selected contact are empty when I use this variable. When I 
use just a number that corresponds to a contact in my array (instead of 
athis variable) that contact displays fine. So looks like everything else 
is working. Probably the scope gets overwritten after ther pageswitch.
Could anyone point me in the right direction?

Marc

-- 
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/groups/opt_out.

Reply via email to