core
No
When my-directive is used in app-root and the directive is declared in a sub-module (library) the viewchild is undefined.
When declaring a directive in the same module where the app-root is declared everything works.
https://anjunar.github.io/angular-simplicity/dist/documentation-app
(The Console shows undefined and Xr)
https://github.com/anjunar/angular-simplicity/blob/master/projects/documentation-app/src/app/app.component.ts
(Here viewport and test as ViewChild, with console out)
https://github.com/anjunar/angular-simplicity/blob/master/projects/documentation-app/src/app/app.component.html
(the as-viewport and app-test at the end)
https://github.com/anjunar/angular-simplicity/blob/master/projects/angular-simplicity/src/lib/as-viewport/as-
as-viewport.directive.ts
https://github.com/anjunar/angular-simplicity/blob/master/projects/documentation-app/src/app/app-test/app-test.component.ts
app-app-test.directive.ts
@ViewChild(MyDirective) directive! : MyDirective is undefined
ng version
)Angular CLI: 15.1.1
Node: 19.4.0 (Unsupported)
Package Manager: npm 9.2.0
OS: win32 x64
Angular: 15.1.0
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
@angular-devkit/architect 0.1501.1
@angular-devkit/build-angular 15.1.1
@angular-devkit/core 15.1.1
@angular-devkit/schematics 15.1.1
@angular/cli 15.1.1
@schematics/angular 15.1.1
ng-packagr 15.1.1
rxjs 7.8.0
typescript 4.9.4
And @pkozlowski-opensource beat me to it :-)
I have found the mistake...
import {AsViewportDirective} from "../../../angular-simplicity/src/lib/as-viewport/as-viewport.directive";
import {WindowManagerService} from "../../../angular-simplicity/src/lib/window-manager.service";
it must be:
import {AsViewportDirective} from "angular-simplicity";
import {WindowManagerService} from "angular-simplicity";
Owner Name | angular |
Repo Name | angular |
Full Name | angular/angular |
Language | TypeScript |
Created Date | 2014-09-18 |
Updated Date | 2023-03-21 |
Star Count | 87006 |
Watcher Count | 3028 |
Fork Count | 23170 |
Issue Count | 1418 |
Issue Title | Created Date | Updated Date |
---|