On my homepage I have a component that gets the top 3 latest posts from an API call:
<recent-posts></recent-posts>
Inside the .ts
file I get the posts like so:
posts: Object;
const().......
this.posts = this.route.snapshot.data.data;
The call is made in the resolve:
path: '',
component: HomeComponent,
pathMatch: 'full',
resolve: {
data: RecentPostResolver
}
Which has this code:
resolve(): Observable<any> {
return this.d.getItems('story', {limit: 3});
}
I want to be able to re-use this component on another page which will then get 6 latest posts.
I bound a parameter to a limit
on the component like so
<recent-posts [limit]="6"></recent-posts>
and int he .ts
for that component I added:
@Input() limit;
and in the ngOnit()
to console log out the limit
and whatever value I put in, it shows so that bit is working.
My questions is, How do I pass that passed in value to the Resolve so I can re-use this component to on many pages with different values?