Reputation: 4599
I have created the custom pagination component using Angular2 but while try to use it in another component, getting the following error
Can't bind to 'offset' since it isn't a known property of 'app-pagination'.
import { PaginationComponent } from './components/pagination.component';
import { ComplaintModule } from './pages/complaints/complaints.module';
import { App } from './app.component';
@NgModule({
bootstrap: [App],
declarations: [
App,
PaginationComponent
],
imports: [ // import Angular's modules
BrowserModule,
ComplaintModule
]})
export class AppModule {
constructor(public appState: AppState) {
}
}
Try to integrate in the following html file
<app-pagination [offset]="offset" [limit]="limit" [size]="count" (pageChange)="onPageChange($event)"></app-pagination>
@Component({
selector: 'app-pagination',
templateUrl: './pagination.component.html',
styleUrls: ['./pagination.component.scss']
})
export class PaginationComponent implements OnInit, OnChanges {
@Input() offset: number = 0;
@Input() limit: number = 1;
@Input() size: number = 1;
@Input() range: number = 3;
constructor() { }
}
Upvotes: 0
Views: 199
Reputation: 4335
You need to create a seperate SharedModule
for using PaginationComponent
in multiple modules
shared.module.ts
@NgModule({
declarations: [
PaginationComponent
],
exports: [
PaginationComponent
]
})
export class SharedModule {
}
complaint.module.ts
@NgModule({
imports: [
SharedModule,
...
]
...
})
export class ComplaintModule {
}
some-other.module.ts
@NgModule({
imports: [
SharedModule,
...
]
...
})
export class SomeOtherModule {
}
Now you should be able to use PaginationComponent
in both ComplaintModule
and SomeOtherModule
Upvotes: 3