Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Angular2- Polymer
Is it possible to keep the PolymerElement("polymer-element-name") declarations in a single Angular2 Module and have its children benefit from it?
I see that at the moment i have to declare the elements in each child module, otherwise they wont benefit from it.
I've tried exporting the declarations from my shared module but i get the following error:
"Can't export directive class5 from SharedAppModule as it was neither declared nor imported!".
While this is not a major issue, its a bit annoying at times. Is it possible to achieve this in any way?
Thanks
Hi! I think you could create a global function and in the declarations just call that function and it would return all the PolymerElement and other declarations. This way you wouldn't have to write same declarations again manually. Let me know if it works.
Hey there and thank you for your reply. Sorry for being so late with a reply.
I tried creating a Polymer declarations constants variable that gets exported and import it into each of my modules declarations, but angular detects this as me declaring the same class multiple times in my modules and throws a error:
"Type class0 is part of the declarations of 2 modules: AppModule and GroupsModule! Please consider moving class0 to a higher module that imports AppModule .... etc"
The way i did it was :
import { PolymerElement } from "@vaadin/angular2-polymer";
export const POLYMER_DECLARATIONS = [
PolymerElement("paper-input"),
PolymerElement("paper-drawer-panel"),
PolymerElement("paper-card"),
... etc
];
and in my modules:
import {POLYMER_DECLARATIONS} from './config/polymer.constants';
@NgModule({
declarations: [
...some declarations,
...POLYMER_DECLARATIONS
],
imports:[]
Am i doing something wrong? Have i missunderstand your suggestion? Sorry again for the late reply!