File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,8 @@ digest duration for several selectors and print sorted table starting with the s
7777* [ ng-count-digest-cycles.js] ( ng-count-digest-cycles.js ) - counts number of full digest cycles (from the root scope)
7878that run when a scope method executes. Useful because sometimes you can get away with just a local digest
7979cycle, rather than a full update. See [ Local Angular scopes] ( http://glebbahmutov.com/blog/local-angular-scopes/ ) .
80+ * [ ng-throw-error.js] ( ng-throw-error.js ) throws an error from the digest cycle; useful for checking
81+ if your [ exception handler] ( http://glebbahmutov.com/blog/catch-all-errors-in-angular-app/ ) is working.
8082
8183All snippets, including mine are distributed under MIT license.
8284
Original file line number Diff line number Diff line change 1+ // throws an exception from the digest cycle
2+ // useful to test your exception handler service
3+ // http://glebbahmutov.com/blog/catch-all-errors-in-angular-app/
4+ ( function throwErrorFromAngular ( angular ) {
5+
6+ if ( typeof angular === 'undefined' ) {
7+ throw new Error ( 'Cannot find angular on the page' ) ;
8+ }
9+ // select any element in the Elements panel that is inside Angular app
10+ /* global $0 */
11+ var injector = angular . element ( $0 ) . injector ( ) ;
12+ if ( ! injector ) {
13+ throw new Error ( 'Cannot find injector, please select an element\n' +
14+ 'INSIDE an angular app in the Elements panel' ) ;
15+ }
16+ injector . get ( '$rootScope' ) . $apply ( function ( ) {
17+ throw new Error ( 'Error from Angular digest cycle' ) ;
18+ } ) ;
19+ } ( window . angular ) ) ;
You can’t perform that action at this time.
0 commit comments