I’m new with the angularjs and I want your help. I’m trying to include the $routeProvider into my project in order to use templating system.
$routeProvider.when('/admin.php?page=all_transactions', { templateUrl : 'pages/home.html', controller : 'TransactionsController' });
I saw that most of the examples i found the url of .when had the following format /route1/:param for urls like #/route1/12345
Because I’m using the angular in wordpress admin page I want the .when
to work with $_GET parameters like the one I gave with the example code.
The depth of parameters I want it to be up to 3 and ignore any other parameters.
Does anyone know how I can do it?
is it enough for u to know, that the params are there? Or do u need explicit values.
If the params are enough u could follow this example: URL Routing with Query Parameters
If you need to have more than one, separate them with an ‘&’:
Hope this helps.
Edit: For accessing the values u can do the following: Accessing query parameter values
OR:
While routing is indeed a good solution for application-level URL parsing, you may want to use the more low-level $location service, as injected in your own service or controller:
This simple syntax will work for http://example.com/path?myParam=someValue. However, only if you configured the $locationProvider in the html5 mode before:
Otherwise have a look at the http://example.com/#!/path?myParam=someValue “Hashbang” syntax which is a bit more complicated, but have the benefit of working on old browsers (non-html5 compatible) as well.