$ routeParams.value is undefined when switching to the new controller

advertisements

I'm trying to pass a value from one controller to another. Using $routeParams as the method for doing this.

My main app references:

var app = angular.module('acnApp', ['ngResource', 'ngRoute'])

To pass the value:

    //GO TO EDIT
$scope.getOrgDetails = function (orgId) {
    console.log(orgId)
    $location.path('/network_org/edit/' + orgId)
}

In my routes.js:

        $routeProvider.when('/network_org/edit/:acnId', {
        templateUrl: 'Pages/acn/orgs/network_org_edit.html',
        controller: 'orgUpdateController'
    });

On the receiving controller:

app.controller('orgUpdateController', ['$scope', '$location', '$routeParams',  function ($scope, $location, $routeParams) {
console.log($routeParams.orgId)}]);

When I run this, the console result is "undefined"

Any help appreciated.


Try the method "url" rather than "path". like this :

$location.url('/network_org/edit?orgId=' + orgId)