Angularjs url rewriting and get variables values

Hi experts,

In my site i was getting the url variables values this way:
// url -> http://mysite.com/index.php?topics=blablatopis&distri=distri123
$scope.topics = $location.search()['topics'];
$scope.months = $location.search()['distri'];

Open in new window


But now were turning the url into "pretty urls" with htaccess like this: "http://mysite.com/index.php/blablatopis/distri123"
How can i get the values now in Angularjs? :\

I tried to understand better the ngRoute.. but i don't know if that helps in anyway in my case.. and the documentation of ngRoute it's kind of poor or maybe it's just me, i don't know...

Thx in advanced,
Miguel
LVL 1
justaphaseAsked:
Who is Participating?
 
Mark BullockQA Engineer IIICommented:
Try this
$scope.topics = $location.path().split("/")[2]
$scope.months = $location.path().split("/")[3]

Open in new window

0
 
leakim971PluritechnicianCommented:
Maybe : https://docs.angularjs.org/api/ngRoute/service/$routeParams
you need to set html5mode to true also : https://docs.angularjs.org/api/ng/provider/$locationProvider

but I'm not sure you need ngRoute because it's for a single page application
that mean you load only part of your page
0
 
justaphaseAuthor Commented:
Amazing Mark!

Thx!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.