Reputation: 1097
I am trying to capture a route to be something like
www.mysite.com/#name=ted&location=ca
I am using stateprovider
and I setup as follow:
$stateProvider
.state('home', {
url: '/#name',
controller: function () {
alert('here')
do stuff...
}
})
but for some reason, alert never trigger.
Can someone help me about it? Thanks a lot!
Upvotes: 0
Views: 35
Reputation: 861
When using ui.router, all routes need a template, include that in your state, remove the #
sign from the URL and it should work
Upvotes: 0
Reputation: 2106
var app= angular.module('appName', []);
app.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/home', {
templateUrl: 'templates/home.html',
controller: 'AddOrderController'
}).
when('/contact', {
templateUrl: 'templates/contact.html',
controller: 'ShowOrdersController'
}).
otherwise({
redirectTo: '/home'
});
}]);
Try This Is Example Of Navigation Using With route Providers .
Upvotes: 0
Reputation: 7764
To get params via query string you can use try:
$stateProvider
.state('home', {
url: '/?name&location',
controller: function () {
alert('here')
do stuff...
}
})
#
will be there if HTML5 mode is disabled.
Upvotes: 0