One way would be to use the ngRoute. Through the $routeProvider
can configure the routes of your site, and with this extract the parameters of the Urls and inject them directly into your controller.
That is to say:
var myApp = angular.module('app', ['ngRoute']); // adicione o ngRoute como modulo do seu modulo
myApp.config(function($routeProvider) {
// indica que quando tiver uma URL do tipo http://localhost/[id], que deve utilizar este template e controlador
$routeProvider.when('/:id', {
templateUrl: '[caminho para a sua pagina HTML]',
controller: 'Controller' // nome do seu controlador
});
})
myApp.controller('Controller', function ($scope, traineeControlService, $routeParams) {
var vm = this;
//getAll();
$scope.numberOfregistrationUser = {};
// var searchObj = $location.url();
console.log($routeParams.id);
}
The object $routeParams
contains all parameters defined in the URL (note when the URL is configured, use of the :
to indicate that a parameter should be read).