Muhsin Mohamed Pc Muhsin Mohamed Pc - 1 year ago 78
AngularJS Question

$location service not passing URL Parameter to Controller

I am trying to pass an ID via URL parameter to a page named "more.html". So the URL Parameter will like the following.

I used $location service in my controller on the more.html page to get the Parameter ID from the URL. Here is the controller code that I used.

var app = angular.module('myApp', []);
app.controller('customersCtrl', function($location, $scope, $http) {
var sno = $;

The result I got from the above code was "Undefined".

Answer Source

Change you url structure as following (adding #)



Adding the # more.html and before your url parameters will fix the problem. Maybe for your next project you could make use of ui-router, which is a more structured way of using parameters.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download