Janbango Janbango - 5 months ago 18
AngularJS Question

Angularjs $routeParams issue

I am struggling to get $routeParams to work. What I want to do is populate an unsubscribe field with an email address that is contained in a link to a url. I am using AngularJS and after reading around the subject is seemed $routeParam was the way to go but I cannot get it to work


<form class="form-signin" name="regForm">
<input type="email" id="email" name="email" class="form-control" ng-model="user.email">

My .config with $routeProvider

.config(['$routeProvider', function ($routeProvider) {
.when('/unsubscribe/:email', {
templateUrl: 'unsubscribe/unsubscribe.html',
controller: 'unsubscribeCtrl'

My .controller with $routeParams

.controller('unsubscribeCtrl', ['$scope', '$location', '$routeParams', function ($scope, $location, $routeParams) {

var param1 = $routeParams.email


Now when I navigate to myURL/app/#/unsubscribe?email=some_text the browser remains blank and I do not get any errors in the console. Am I mis-understanding how $routeParams is supposed to work?


The url you are trying to access doesn't match the given route in $routeparams table. You should try to navigate app/#/unsubscribe/some_text. The $routeparams will understand that email is some_text