0

I have designed a small app in angular JS. Where I have various menus on left. I am facing an issue when I click on backspace button. When I click on backspace button it comes to

$rootScope.$on('$routeChangeSuccess',function(){
// here i am checking the user is logged in or not
}

My question is why application changes the route when I click on back space button?

I have configured the routeProvider correctly. So any one can please help me out.

P̲̳x͓L̳
  • 3,547
  • 3
  • 28
  • 37
Shardul Pendse
  • 274
  • 1
  • 4
  • 17
  • 1
    Backspace in many browsers is used to go back one page so it is probably changing your route. You can prevent default on events if you can capture them. – shaunhusain Mar 22 '14 at 21:24
  • thanks for a quick reply. I am using chrome browser. i have figured it out that. but i am enable to capture the event. I have used event.keyCode but it always gives me an undefined values – Shardul Pendse Mar 22 '14 at 21:27
  • hmm can you show this in action in a plunkr? I just did one with a ng-keyup ng-keydown handlers to prevent default for scrolling and it seemed to work. You need to pass through $event in the handler if you define it in the HTML – shaunhusain Mar 22 '14 at 21:28
  • hey from stack overflow i got the solution – Shardul Pendse Mar 22 '14 at 21:40
  • http://stackoverflow.com/questions/21169298/is-there-an-angularjs-way-to-have-a-press-of-a-key-call-a-routine-in-my-controll?lq=1 – Shardul Pendse Mar 22 '14 at 21:41
  • Great glad you got it sorted you can eventually post it as an answer to your own question I believe (might be a delay since you're a relatively new SO user) – shaunhusain Mar 22 '14 at 21:42

0 Answers0