app.config(function($stateProvider, $urlRouterProvider) { $stateProvider .state('home', { url: '/home', templateUrl: 'templates/home.html' }) .state('index', { url: '/login', templateUrl: 'templates/login.html', }) $urlRouterProvider.otherwise('/login'); }) app.controller('Login', function($scope, $rootScope, $state) { $scope.input = { login: '', pass: '' } $scope.getUser = function(input) { if($scope.input.pass.length > 3) { console.log("Verificated!"); } else { console.log('Wrong pass!'); }; }; });
https://embed.plnkr.co/7xFjPgU9zUXaDJO7Lc4B/
How to prevent navigating if some_condition?