I need to read URL parameters from browser and assign it to a variable. My url will be like http://localhost:9090/ngdemo/apd.html?id=bookid-1 . I need to get bookid-1 from the url. I tried $location.search(), $location.$$path but I am not getting the value 'bookid-1' .
My controller code is
app.controller('apdController', function($scope, getTocService,$location,$routeParams) {
var bookId = $location.search();
var param1 = $routeParams.param1;
});
app.js
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/view3/:param1', {templateUrl: 'apd.html', controller: 'apdController'});
$routeProvider.otherwise({redirectTo: '/view1'});
}]);
What is the change I need to make to get bookid-1 here?
$location.search().id?id, notbookIdnorparam1. have you triedvar bookId = $routeParams.id;?ui-routerorng-router?