How do i get the value of pk
in the ng-href
and how do i call it into my controller.js
?
Asked
Active
Viewed 101 times
-6
-
2Please post the relevant code in the question itself, along with anything you have tried and explain what went wrong with it. A link to an image is not a suitable question for Stack Overflow. – Reinstate Monica Cellio Nov 25 '16 at 10:42
-
sorry guys :( i'll try to be specific next time – J.Rayga Nov 25 '16 at 10:58
-
3You can edit this question now - no need to wait till next time :) – Reinstate Monica Cellio Nov 25 '16 at 11:00
1 Answers
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