Custom directive inheritance problem
See original GitHub issue🐞 bug report
Affected Package
Packages :
“scripts”: { “ng”: “ng”, “start”: “ng serve”, “build”: “ng build”, “test”: “ng test”, “lint”: “ng lint”, “e2e”: “ng e2e” }, “private”: true, “dependencies”: { “@angular/animations”: “~7.2.0”, “@angular/common”: “~7.2.0”, “@angular/compiler”: “~7.2.0”, “@angular/core”: “~7.2.0”, “@angular/forms”: “~7.2.0”, “@angular/platform-browser”: “~7.2.0”, “@angular/platform-browser-dynamic”: “~7.2.0”, “@angular/router”: “~7.2.0”, “@ng-bootstrap/ng-bootstrap”: “^4.1.3”, “angular-font-awesome”: “^3.1.2”, “core-js”: “^2.5.4”, “font-awesome”: “^4.7.0”, “rxjs”: “~6.3.3”, “tslib”: “^1.9.0”, “zone.js”: “~0.8.26” }, “devDependencies”: { “@angular-devkit/build-angular”: “~0.13.0”, “@angular/cli”: “~7.3.8”, “@angular/compiler-cli”: “~7.2.0”, “@angular/language-service”: “~7.2.0”, “@types/jasmine”: “~2.8.8”, “@types/jasminewd2”: “~2.0.3”, “@types/node”: “~8.9.4”, “bootstrap”: “^4.3.1”, “codelyzer”: “~4.5.0”, “jasmine-core”: “~2.99.1”, “jasmine-spec-reporter”: “~4.2.1”, “jquery”: “^3.4.1”, “karma”: “~4.0.0”, “karma-chrome-launcher”: “~2.2.0”, “karma-coverage-istanbul-reporter”: “~2.0.1”, “karma-jasmine”: “~1.1.2”, “karma-jasmine-html-reporter”: “^0.2.2”, “ng-multiselect-dropdown”: “^0.2.3”, “ngx-toastr”: “^10.0.4”, “popper”: “^1.0.1”, “protractor”: “~5.4.0”, “ts-node”: “~7.0.0”, “tslint”: “~5.11.0”, “typescript”: “~3.2.2” }
Is this a regression?
Unknown.
Description
A custom directive (attribute) is unknown in submodule when declared in root module. I have a global directive with “appGlobal” selector. If i declare it in root module only, i get the following error :
- “Can’t bind to ‘appGlobal’ since it isn’t a known property of ‘span’. (” <span [ERROR ->][appGlobal]=“‘Menu_Admin_Dashboard’”>Dashboard</span> <a class=“btn btn-primary” routerLink=“/a”): ng:///AdministrationModule/AdminComponent.html@0:65 . . . ng:///AdministrationModule/AdminComponent.html@2:61"
But, if i declare it in the admin submodule, i get the obvious following error :
- “0: Type GlobalDirective is part of the declarations of 2 modules: AdministrationModule and AppModule! Please consider moving GlobalDirective to a higher module that imports AdministrationModule and AppModule. You can also create a new NgModule that exports and includes GlobalDirective then import that NgModule in AdministrationModule and AppModule.”
🔬 Minimal Reproduction
As explained in the description. Also too busy to take time to make a reproduction, sorry.
🔥 Exception or Error
0: Type GlobalDirective is part of the declarations of 2 modules: AdministrationModule and AppModule! Please consider moving GlobalDirective to a higher module that imports AdministrationModule and AppModule. You can also create a new NgModule that exports and includes GlobalDirective then import that NgModule in AdministrationModule and AppModule.
0: Template parse errors:
Can't bind to 'appGlobal' since it isn't a known property of 'span'. (" <span [ERROR ->][appGlobal]="'Menu_Admin_Dashboard'">Dashboard</span>
Dashboard</span>
<span [ERROR ->][appGlobal]="'Menu_Admin_Users'">Users</span>
Users</span>
<span [ERROR ->][appGlobal]="'Menu_Admin_Roles'">Roles</span>
<div class="container">
"): ng:///AdministrationModule/AdminComponent.html@2:61
🌍 Your Environment
Angular Version:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 7.3.9
Node: 11.2.0
OS: win32 x64
Angular: 7.2.15
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.13.9
@angular-devkit/build-angular 0.13.9
@angular-devkit/build-optimizer 0.13.9
@angular-devkit/build-webpack 0.13.9
@angular-devkit/core 7.3.9
@angular-devkit/schematics 7.3.9
@angular/cli 7.3.9
@ngtools/webpack 7.3.9
@schematics/angular 7.3.9
@schematics/update 0.13.9
rxjs 6.3.3
typescript 3.2.4
webpack 4.29.0
Anything else relevant? Using Visual Studio Code 1.34.0 (latest version at the moment)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Thanks, but i think i made it clear that i already knew that. What i’m saying is that, as the error message states, it should propagate the knowledge of the directive to all submodules instead of forcing me to make a useless shared module only for this case.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.