javascript - AngularJS Redirecting after displaying the parameter -
this continuation of my question
so far didn't url value. can able url paameter problem page getting redirected once showing alert
here controller , 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 url this
http://192.168.1.58/myapp/#/showprofile/18
after showing alert 18
it makes url
http://192.168.1.58/myapp/#/showprofile/:userid
how can stop redirection .. ??
i want final url
i found problem because of .run
function have.
after removing works good.
here .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 redirect'); $location.path(nexturl); } else { console.log('not logged in'); $location.path('login'); } } }); }); });
Comments
Post a Comment