1

I have a weird bug in my AngularJS application. I have a form, in which I have an select-block, where i can choose an item. So I choose an item and click "Save". Now when I select another item in the same block, as soon as I click anywhere on the screen it will change it back to the value before.

Scenario:

  1. Select Item A from Dropdown --> Item A selected
  2. Select Item B from Dropdown --> Item B selected
  3. Click anywhere on the screen --> Item A selected again

So I need to investigate where in my code the change is being made. So I decided to use scope.$watch() and set a Breakpoint in it. However this now only shows me the Angular Library in the callstack and the $digest cycle. But nothing from my code.

Now how can I approach this? Is there another trick to see, why my application is resetting the value after I click anywhere?

user5417542
  • 3,146
  • 6
  • 29
  • 50
  • have you already tried using the chrome console? – Leo Dec 12 '17 at 11:32
  • What do you mean by that? – user5417542 Dec 12 '17 at 11:34
  • 1
    you can set breakpoints and debug decently with chrome dev tools – ThatBrianDude Dec 12 '17 at 11:34
  • try looking at this, maybe it helps you https://developers.google.com/web/tools/chrome-devtools/javascript/breakpoints – Leo Dec 12 '17 at 11:35
  • You get me wrong ^^. I know how to debug, that's what I wrote in my description. I set a breakpoint inside the $watch callback. But I don't know how I can find the method in my code, which is causing the change to my variable and thus $watch being called. – user5417542 Dec 12 '17 at 11:35
  • ok, but if you use the debug console, you can put the breakpoints where you use that variable, and see where it changes, and then go back to what function is the cause of the change... or share your code ^_^ – Leo Dec 12 '17 at 11:38
  • if you create a https://jsfiddle.net/ , we can help you more easily – Leo Dec 12 '17 at 11:40
  • As I said, I have a Breakpoint and I can see the Callstack. However it is only Angular related, because of the $watch function, which comes from Angular. So I need to investigate why in the next digest cycle (which I interpret as my click) the value changes. I don't think code will help you, since the application is quite huge and I don't want to know the error, I just want help with finding it ^^ – user5417542 Dec 12 '17 at 11:44
  • start debugging from handler of that click event and see value of your variable – sandyJoshi Dec 12 '17 at 11:46
  • 1
    Possible duplicate of [How to “break on property change” in chrome?](https://stackoverflow.com/questions/11618278/how-to-break-on-property-change-in-chrome). – georgeawg Dec 12 '17 at 13:23

0 Answers0