This is the continuation of my question
So far i didn't even get the url value. But now i can able to get the url paameter but the problem is that my page is getting redirected once showing the alert
Here is my controller and route
route
.when('/showprofile/:UserID', {
templateUrl: 'resources/views/layout/showprofile.php',
controller: 'ShowUserCtrl'
})
Controller ;
app.controller('ShowUserCtrl', function($scope, $routeParams) {
var b = $routeParams.UserID;
alert(b);
$scope.userid = $routeParams.UserID;
});
My View :
{{userid}}
The problem is My Url is like this
http://192.168.1.58/myapp/#/showprofile/18
After showing the alert 18
It makes the url like
http://192.168.1.58/myapp/#/showprofile/:UserID
How can i stop the redirection .. ??
I just want this as my final url
I found that the problem is because of .run
function that i have.
After removing it works good.
Here is my .run
function
.run(function ($rootScope, $location, Data, $http) {
$rootScope.$on("$routeChangeStart", function (event, next, current) {
$http.post('CheckSession', {}).then(function (results)
{
console.log(results.data);
var nextUrl = next.$$route.originalPath;
if (nextUrl == '/signin' || nextUrl == '/login' || nextUrl == '/verify' || nextUrl == '/registration' || nextUrl == '/forget' || nextUrl == '/invalidtoken' || nextUrl == '/registersuccess')
{
console.log('outpages');
}
else
{
if (results.data == 1)
{
console.log('loggedin');
console.log(nextUrl);
console.log('to be redirect');
$location.path(nextUrl);
}
else {
console.log('not logged in');
$location.path('login');
}
}
});
});
});