@@ -19,6 +19,7 @@ import { unnestR } from "./shared/common.js";
1919import { EventBus } from "./services/pubsub/pubsub.js" ;
2020import { $injectTokens as $t } from "./injection-tokens.js" ;
2121import { annotate } from "./core/di/di.js" ;
22+ import { validateIsString } from "./shared/validate.js" ;
2223
2324const ngMinErr = minErr ( "ng" ) ;
2425
@@ -39,6 +40,9 @@ export class Angular {
3940 /** @public @type {ng.PubSubService } */
4041 this . $eventBus = EventBus ;
4142
43+ /** @public @type {ng.InjectorService } */
44+ this . $injector ;
45+
4246 /**
4347 * @public
4448 * @type {string } `version` from `package.json`
@@ -263,10 +267,15 @@ export class Angular {
263267 return x . $$state ( ) . resolvables ;
264268 } )
265269 . reduce ( unnestR , [ ] )
266- . filter ( ( x ) => {
267- return x . deps === "deferred" ;
268- } )
270+ . filter (
271+ /** @param {import("./router/resolve/resolvable.js").Resolvable } x */ (
272+ x ,
273+ ) => {
274+ return x . deps === "deferred" ;
275+ } ,
276+ )
269277 . forEach (
278+ /** @param {import("./router/resolve/resolvable.js").Resolvable } resolvable */
270279 ( resolvable ) =>
271280 ( resolvable . deps = annotate (
272281 resolvable . resolveFn ,
@@ -281,18 +290,20 @@ export class Angular {
281290
282291 /**
283292 * @param {any[] } modules
284- * @param {boolean? } strictDi
285- * @returns {import("./core/di/internal-injector.js") .InjectorService }
293+ * @param {boolean } [ strictDi]
294+ * @returns {ng .InjectorService }
286295 */
287296 injector ( modules , strictDi ) {
288- return createInjector ( modules , strictDi ) ;
297+ this . $injector = createInjector ( modules , strictDi ) ;
298+
299+ return this . $injector ;
289300 }
290301
291302 /**
292303 * @param {Element|Document } element
293304 */
294305 init ( element ) {
295- /** @type {Element } */
306+ /** @type {Element|undefined } */
296307 let appElement ;
297308
298309 let module ;
@@ -339,10 +350,14 @@ export class Angular {
339350 * or defined on `$scope` injectable.
340351 *
341352 * @param {string } name
342- * @returns {ProxyHandler <ng.Scope>|undefined }
353+ * @returns {Proxy <ng.Scope>|undefined }
343354 */
344355 getScopeByName ( name ) {
345- const scope = this . $rootScope . $searchByName ( name ) ;
356+ validateIsString ( name , "name" ) ;
357+ /** @type {ng.RootScopeService } */
358+ const $rootScope = this . $injector . get ( "$rootScope" ) ;
359+
360+ const scope = $rootScope . $searchByName ( name ) ;
346361
347362 if ( scope ) {
348363 return scope . $proxy ;
0 commit comments