1

I'm building a little Chrome extension to interact with Angular website. I can catch full page reload successfully via $(document).ready(), but page changes via ng-view don't change ready state, so I'm not sure how to catch that event from within a Chrome extension.

How should I go about catching ng-view changes from Chrome extension? Preferably without introducing extension dependency to AngularJS.

Ruslan Osipov
  • 5,655
  • 4
  • 29
  • 44
  • 1
    Have you tried listening for the popstate event? – dewd Nov 25 '14 at 20:43
  • @dewd No, I'll have to try. I am afraid of the issue with popstate changing before the DOM is rendered though. – Ruslan Osipov Nov 25 '14 at 20:50
  • Thats a possibilty. Haven't used angular for about 18 months so don't recall even if pushstate is used - it might not be as its not pre IE10. I'm sure someone who knows more about the view/ state relationship will be able to help. – dewd Nov 25 '14 at 20:55
  • @dewd, Tried the popstate, doesn't look like it's working. I think URL changes before there's DOM to manipulate. – Ruslan Osipov Nov 25 '14 at 21:20
  • ..which makes sense. popstate does get triggered though? in any case, looks like elzi's more on the right track. – dewd Nov 26 '14 at 12:08

1 Answers1

0

The DOM ready equivalent for angular is

angular.element(document).ready(function () {
    console.log('Hello World');
});

If you want to detect a view change, you can look at $httpProvider.responseInterceptors. Check out the first answer in this SO question

EDIT I see now you mean detecting angular events from outside of angular? I'll leave my answer here - though it is likely not an exact answer to your question.

Community
  • 1
  • 1
elzi
  • 5,442
  • 7
  • 37
  • 61