ion-view is not a known element
Solution 1
ion-view is a valid component in ionic version 1 and not available in version 2.
In order to set image background you can set a css class and set 'background' attribute
<ion-content class="view-class">
Hello!
</ion-content>
In your corresponding scss
.view-class {
background: url("path_to_image")
}
EDIT: sample plunker
Solution 2
i Dont know much about ionic but seems error is in module
<ion-view view-title="My Page">
<ion-content>
Hello!
</ion-content>
</ion-view>
according to error if you are using ion-view
or any component in your app, than you must add that component in the main module.
like in angular2 we did the same in app.module.ts
file where we tell the angular which components are we going to be load on the load of app.
like this
@NgModule({
declarations: [
here component list, directives and pipes
],
imports: [
ion-view, etc.....
],
providers: [CanActivateViaAuthGuard, GlobalService],
bootstrap: [AppComponent]
})
export class AppModule { }
manish kumar
Updated on June 27, 2022Comments
-
manish kumar almost 2 years
following is my content for ionic page:
<ion-content padding class = ""view-content"> <form> [form content here...] </form> </ion-content>
my css file:
.view-content { background: url("background.jpg");
but it is not working and i'm getting the following error:
Unhandled Promise rejection: Template parse errors: 'ion-view' is not a known element: 1. If 'ion-view' is an Angular component, then verify that it is part of this module. 2. If 'ion-view' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. (" [ERROR ->]<ion-view view-title="My Page"> <ion-content> Hello! ")
can any tell me what am I doing wrong here or how to solve this. I'm new to ionic framework, infact new to web development.
-
JoeriShoeby over 7 years<ion-view> is a directive from the Ionic Framework, you're answer is wrong.
-
Pardeep Jain over 7 yearsokay so you can put your directives in the decalration part. is it right ?
-
manish kumar over 7 yearsso any idea about how to add a background as an image for a page in ionic 2?
-
manish kumar over 7 yearsi'm able to set background color but not an image.
-
Suraj Rao over 7 yearsits working in the plunker.. give the relative path to your image.. it should work
-
manish kumar over 7 yearsmy image is in the same folder as my other scss and html files. path is correct.
-
manish kumar over 7 yearsits for testing purpose only...so that i can get it to work....i don't think that path is an issue
-
Suraj Rao over 7 yearson the contrary.. ionic will build it and move it accordingly to the www folder from assets.. it wont move images from src..