Here is the app.js of my project:
(function () {
\'use strict\';
angular
.module(\'app\', [\'ui.router\', \'ngCookies\', \'angular-inview\', \'ngMateria
You need to execute the $state.go
on main scope and not in a (angular) service or virtual scope created temporarily.
You can also solve the problem by wrapping it in $timeout
or setTimeout
which will register it in the browser loop to be executed after the current method run etc even with 0 milliseconds will do it, like.
$timeout(()=>{$state.go('xyz')},0)
or
setTimeout(()=>{$state.go('xyz')},0);
Well, thanks to @Vanojx1, I found out adding e.preventDefault();
before the $state.go('login');
made it work. Still dont understand why though.