Unexpected value 'HTMLImageElement' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation


#1

Hi
i am getting this issue while running ionic serve
i got this problem when i deleted some of the code which i am not using and deleted it from the app.module.ts file also
Earlier it was working fine


#2

import { BrowserModule } from ‘@angular/platform-browser’;
import { NgModule, ErrorHandler } from ‘@angular/core’;
import { IonicApp, IonicModule, IonicErrorHandler } from ‘ionic-angular’;
import { MyApp } from ‘./app.component’;

//import { ItemDetailsPage } from ‘…/pages/item-details/item-details’;

import { ListPage } from ‘…/pages/list/list’;
import { ContactPage } from ‘…/pages/contact-page/contact-page’;
import { AboutPage } from ‘…/pages/about-page/about-page’;
import { AngularPage } from ‘…/pages/angular-page/angular-page’;
import { Angular2Page } from ‘…/pages/angular2-page/angular2-page’;
import { Rewrite } from ‘…/pages/rewrite/rewrite’;
import { Sample } from ‘…/pages/sample/sample’;
import { Enviornment } from ‘…/pages/enviornment/enviornment’;
import { Http } from ‘…/pages/http/http’;
import { Decorator } from ‘…/pages/decorator/decorator’;
import { Routing } from ‘…/pages/routing/routing’;
import { Ngmodule } from ‘…/pages/ngmodule/ngmodule’;
import { Template } from ‘…/pages/template/template’;

import { Dependency } from ‘…/pages/dependency/dependency’;
import { Guards } from ‘…/pages/guards/guards’;
import { Observables } from ‘…/pages/observables/observables’;
import { Installation } from ‘…/pages/installation/installation’;

import { IonicImageViewerModule } from ‘ionic-img-viewer’;

import { StatusBar } from ‘@ionic-native/status-bar’;
import { SplashScreen } from ‘@ionic-native/splash-screen’;

@NgModule({
declarations: [
MyApp,
// ItemDetailsPage,
ListPage,
ContactPage,
AboutPage,
AngularPage,
Angular2Page,
Rewrite,
Sample,
Enviornment,
Http,
Decorator,
Routing,
Ngmodule,
Template,
Image,
Dependency,
Guards,
Observables,
Installation
],
imports: [
BrowserModule,
IonicImageViewerModule,
IonicModule.forRoot(MyApp),
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
// ItemDetailsPage,
ListPage,
ContactPage,
AboutPage,
AngularPage,
Angular2Page,
Rewrite,
Sample,
Enviornment,
Http,
Decorator,
Routing,
Ngmodule,
Template,
Image,
Dependency,
Guards,
Observables,
Installation

],
providers: [
StatusBar,
SplashScreen,
HTMLImageElement,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
This is my app.module file


#3

Have you added a @Pipe, @Directive, or a @Component decorator to HTMLImageElement?


#4

HTMLImageElement is declared in the dom library. I find creating things with that clash with stuff in standard libraries is a recipe for pain, because my IDE has no way of knowing that I need an import for them. Assuming it’s something you created, I’d rename it (ditto for Decorator and Http). If it’s supposed to be the actual DOM class, get it out of providers. You don’t provide that.

I think your life would also become easier if you named your pages more consistently, instead of some of them having Page and some not.


#5

will i get solution…if i will create a new project and add this code into the new one…with page at end


#6

You still haven’t explained what you are trying to do with HTMLInputElement.


#7

i am not using HTMLInputElement anywhere in my code.


#8

Sorry, I misspoke. I meant HTMLImageElement.


#9

No…i am not using HTMLImageElement anywhere.
not in my module file, not in my page, not in overall project.
My code was running, after complition the code i just deleted some of my pages that i am not using and deleted the iport part as well as declaration and after this issue is coming


#10

It seems to be listed in the providers stanza of your app module as posted above. Are you saying you took that out? If so, it’s mysterious that it would be mentioned in an error as described in the topic headline.


#11

No it was not in the provider…it was not in the list earlier also.


#12

Do you not see it in this post?


#13

no…it was not earlier


#14

I’m confused. Are you saying that gremlins edited your post, or am I misreading what you wrote? I clearly see:

providers: [
StatusBar,
SplashScreen,
HTMLImageElement,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]


#15

oh sorry…i pasted it wrong the HTMLImageElement was not there…i just wrote it when i was debugging sorry for this
but the issue is same


#16

I’m sorry, but I have a very difficult time believing you get an error referencing HTMLImageElement (as is in the topic headline) when you have removed every single reference to that class in your code.


#17

Hi @rapropos…Thanks for your support
i am unable to find the issue.so i created a new project and paste this code in that
Now it’s working fine.
Thanks again :slight_smile:


#18

@rapropos can u check one of my issue