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
77
77
* [ ng-count-digest-cycles.js] ( ng-count-digest-cycles.js ) - counts number of full digest cycles (from the root scope)
78
78
that run when a scope method executes. Useful because sometimes you can get away with just a local digest
79
79
cycle, 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.
80
82
81
83
All snippets, including mine are distributed under MIT license.
82
84
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