i run ionic serve compile works ok, but when i browse to the page i get a console error:
compiler.js:2427 Uncaught Error: Template parse errors:
'some-thing' is not a known element:
1. If 'some-thing' is an Angular component, then verify that it is part of this module.
2. If 'some-thing' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
</ion-label>
[ERROR ->]<some-thing></some-thing>
</ion-item>
"): ng:///AppModule/AppComponent.html@17:14
at syntaxError (compiler.js:2427)
at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:20311)
at
...
All answers about this seem to point to having to load this component in manually, but it looks like that is already done inside the ‘app.module.ts’
I noticed this in the tabs sample project and thought it was something about lazy loading, but it’s still happening inside a non-tabs projects too.
I had this problem when I was importing the page (component) rather than the module, and it wasn’t giving any compilation errors but then module not known at runtime. In your app.module.ts put your module in the imports list.
Hello, @indraraj26 he creates a ionic project with type angular and then he creates with angular a component. This component is not a webcomponent, so he needs like @arnhrwd wrote to import whatever.component.module and add it to import section like WhateverModule.
@polonski if you use visual code, then there are extensions that will help with imports.
In short, when you wanna use a component in html, then import path points to *module. If this custom component is a webcomponent, then add CUSTOM_ELEMENTS_SCHEMA ( for example a webcomponent created with stencil), otherwise the WatheverModule to import section…
and then the <some-thing></some-thing> element in the app.component.html
Good news: No errors yayz
Bad news: <some-thing></some-thing> is rendering as an empty element, the component html (which is a button) is not rendering (!)
@polonski, at the end… how you fix it…? please share the love… the CUSTOM_ELEMENTS_SCHEMA does not work for me… because the template of component never loads…
I never thought of that - but for some modules (like ionic-context-menu - npm) I had to add it directly to the module of the ionic page I wanted to use it in. Adding it to app.module imports had no effect (and I’m a noob so I don’t understand why)
Hello, @anna_liebt
I was searching for a solution for this issue and I found this comment. This comment explains exactly what I want and I tried to add CUSTOM_ELEMENTS_SCHEMA but I still have the problem and I can not find how I can fix this issue. Could you help me ? Thanks
Yes, I realize that’s overly broad advice, but if you are in a position where you are searching Google and forums to fix problems, I can only implore you to heed it.
I have about 80% confidence that your actual problem stems from a combination of unfortunate factors:
Angular lazy loading is brittle and overly complex
Ionic generators and documentation lock you into it by default
You probably forgot to import something somewhere
To test this theory, make a new branch in your version control system, and try taking the lazy loading completely out. Declare all components in your AppModule, and eliminate all other component-specific modules from your code.
If you don’t want to do that, the next best solution would be for you to provide a link to a publicly-accessible repository that others can use to try to replicate your problem. It is going to be fairly difficult to diagnose anything further with just chitchat and isolated snippets.
You know how every time you declare a custom component, inside its @Component declaration, there’s a selector property? That determines how you embed that component into another template. So if you have:
@Component({selector: "abracadabra", ...})
class AbracadabraComponent {...}
…then in some other page, you would include it like:
<abracadabra></abracadabra>
some-thing is being used in that context in the OP.