in the controller

if (response.user.state == 'active') { $scope.isNewUser = 0; console.log('response.user.email '); console.log(response.user.email); $state.go('login.login' , {'prefillEmail': response.user.email}); // } 

app.js

 .state('login.login', { url: '/login', params: { redirect: { value: '' } }, templateUrl: 'views/login.html', controller: 'loginCtrl', resolve: { redirect: function($stateParams) { return $stateParams.redirect; } } }) 

login.js controller

 (function () { 'use strict'; angular.module('app') .controller('loginCtrl', function($scope, authService, redirect, $state, $location, $stateParams) { $scope.credentials = { email: '', password: '' }; console.log('$stateParams'); console.log($stateParams); console.log('$state'); console.log($state); $scope.authenticate = function() { authService.login($scope.credentials) .then(function(response) { //Redirecting to hostname. Route check user type and return needed URL $location.path(redirect || '/'); }); } }); })(); 

The question is, how do I get the prefillEmail value in the login controller? Through $stateParams nothing comes

    1 answer 1

    To make the parameter available, you need to initialize it via app.js simply by giving it null.

     .state('login.login', { url: '/login', params: { redirect: { value: '' }, prefillEmail: null }, templateUrl: 'views/login.html', controller: 'loginCtrl', resolve: { redirect: function($stateParams) { return $stateParams.redirect; } } }) 

    The answer found here https://github.com/angular-ui/ui-router/issues/928