TheBoubou
TheBoubou

Reputation: 19903

$routeProvide get the value in URL in the view

I have this :

$routeProvider
    .when('/Customer/:id?', {
        templateUrl: templatePath + 'Customer/Detail.html',
        controller: 'myAngularJsController',
        caseInsensitiveMatch: true
    })
    .otherwise({
        redirectTo: '/defaultroute'
    });

The URL is : http://localhost:39765/#/Customer/7

I'd like get the value (7) in my page Detail.html, in an angularJs variable, how can I do this ?

Thanks,

Upvotes: 1

Views: 45

Answers (1)

dfsq
dfsq

Reputation: 193261

Inject $routeParams service into myAngularJsController controller and read param by key

console.log($routeParams.id);

Upvotes: 1

Related Questions