-6

How do i get the value of pk in the ng-href and how do i call it into my controller.js?

Dharman
  • 30,962
  • 25
  • 85
  • 135
J.Rayga
  • 11
  • 3

1 Answers1

1

From what I can tell you're using ngRoute, so in your module app.js, inject ngRoute, and $routeProvider in the config like so;

angular.module("app", ['ngRoute']).config(function($routeProvider){
})();

Then in the body of the configuration;

$routeProvider.when("/candidate/:pk", 
{
     controller: "controller",
     templateUrl: "htmlPage"
}

Now in your controller inject $routeParams, and then;

$scope.pk = $routeParams.pk;

In the future I recommend adding more code, so the question makes a bit more sense, I don't know exactly what you're doing so this is a pretty generic answer.

Tom Johnson
  • 679
  • 5
  • 15