{"id":1801,"date":"2022-08-30T15:19:33","date_gmt":"2022-08-30T15:19:33","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/02\/get-scope-reference-on-rootscope-event-handler-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:19:33","modified_gmt":"2022-08-30T15:19:33","slug":"get-scope-reference-on-rootscope-event-handler-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/get-scope-reference-on-rootscope-event-handler-collection-of-common-programming-errors\/","title":{"rendered":"Get $scope reference on $rootScope event handler-Collection of common programming errors"},"content":{"rendered":"<p>In the <code>.run<\/code> section of the main module of my application, I have an event handler for the <code>$locationChangeStart<\/code> event. I want to use this in order to confirm discarding unsaved changes. The problem is that I need a reference to the <code>$scope<\/code> in order to perform these checks.<\/p>\n<p>I tried adding that reference as I added the one for the <code>$rootScope<\/code>, but I get an error <code>Uncaught Error: Unknown provider: $scopeProvider<\/code><\/p>\n<p id=\"rop\"><small>Originally posted 2013-12-02 01:34:54. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>In the .run section of the main module of my application, I have an event handler for the $locationChangeStart event. I want to use this in order to confirm discarding unsaved changes. The problem is that I need a reference to the $scope in order to perform these checks. I tried adding that reference as [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1801","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1801","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1801"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1801\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}