Firstly, top job on shipping Ionic 3. Having a bit of a play about with it but struggling to get to grips with importing custom components.
If I initialise a page, and it’s corresponding module as per the docs (see below), I get an error stating that my page template cannot bind to the properties of my custom components.
Error Output:
`core.es5.js:1085 ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can’t bind to ‘locations’ since it isn’t a known property of ‘location-search-input’.
- If ‘location-search-input’ is an Angular component and it has ‘locations’ input, then verify that it is part of this module.
- If ‘location-search-input’ is a Web Component then add ‘CUSTOM_ELEMENTS_SCHEMA’ to the ‘@NgModule.schemas’ of this component to suppress this message.
- To allow any property add ‘NO_ERRORS_SCHEMA’ to the ‘@NgModule.schemas’ of this component`
I simply reference my custom component in my markup as follows:
<location-search-input [locations]="searchLocations"></location-search-input>
, which worked perfectly well prior to upgrading and switching to @IonicPage decorators.
Just for clarity here’s a snippet of my custom component, in which locations
is declared as a property/input.
@Component({selector: 'location-search-input', templateUrl: './location-search-input.component.html'})
export class LocationSearchInput {
@Input() locations: any[] = [];
constructor(public navController: NavController, private googlePlacesService: GooglePlacesService) {
}
}
I have a feeling I am perhaps supposed to declare/import my custom component in the page’s Module, but then again I’m not sure. Any advice would be greatly appreciated.
Page Module - as per docs
import {NgModule} from "@angular/core";
import {IonicPageModule} from "ionic-angular";
import {BrowsePage} from "./browse.page";
@NgModule({
declarations: [BrowsePage],
imports: [
IonicPageModule.forChild(BrowsePage),
],
entryComponents: [
BrowsePage,
]
})
export class BrowsePageModule {
}
Thanks!