question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 :

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
madks13commented, Jun 1, 2019

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.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 15, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is inherited child scope in directive | Edureka Community
If there is any change in the child scope those are not reflected in the parent scope. To do this we can use...
Read more >
How do I inherit behaviour of another directive in AngularJS?
I'm looking to have one directive inherit behaviour of another directive, while also providing behaviour of its own. Below is an example case....
Read more >
Directive Inheritance in AngularJS - David Barreto
An actual way to inherit the behavior of another directive in the making of your custom derived directive is to access the original...
Read more >
Missing @Directive()/@Component() decorator migration
When the child class is missing the decorator, the child class inherits from the parent class yet has no decorators of its own....
Read more >
Understanding Scope in Directives for better context
In order to solve the problem we faced with the shared scope in the spinner directive earlier, we can have a separate scope...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found