Reputation:
Here's my url
localhost/project/#/showprofile/18
I want to display the parameter 18
in my view
In the app.js
i have
.when('/showprofile/:UserID', {
title: 'Show User Profile',
templateUrl: 'views/layout/showprofile.php',
controller: 'authCtrl',
})
Here the page showprofile.php
is displaying, but suddenly the url goes like this
localhost/project/#/showprofile/:UserId
How can i get the value 18
inside the showprofile.php
and make the url as it is i.e.,
localhost/project/#/showprofile/18
Upvotes: 0
Views: 96
Reputation: 87203
Use $routeParams
to get the parameter value:
$routeParams.UserID
Make sure you inject $routeParams
before using it.
EDIT How can i get the value 18 inside the showprofile.php
<?php
$link = $_SERVER['PHP_SELF']; // Get current URL
$link_array = explode('/', $link); // Split by /
echo $page = end($link_array); // Get last element from array
?>
Upvotes: 2
Reputation: 63
You can use jquery to get value.
var parts = window.location.pathname.split('/');
var id = parts[parts.length - 1];
Upvotes: -1
Reputation: 8912
You can use $location.path()
.
As an example,
if ($location.path() === 'localhost/project/#/showprofile/18'
{
// logic goes here
}
You need to inject $location
Upvotes: 1