With only the tools of @Input, @Output, routing, and activatedRoute at my disposal, I set out to create a dynamic application.
In this project, there are two crucial components: addbook
and showbook
.
The addbook
component features a form with a submit button designed to store all the entered data upon submission.
Meanwhile, the showbook
component is responsible for displaying the saved form data.
Both components are neatly integrated within a navigation bar consisting of anchor tags. One leads to the addbook
component where users can input their data which should be saved upon submission. The other directs users to the showbook
component where they can view the stored form data.
To achieve this functionality, I have implemented a template-driven form that triggers a function on submission:
this.route.navigate(['showbook', bookID])
Furthermore, I configured the route path as 'showbook/:id' and associated it with the showbook component using RouterModule.forRoot([routes]). Within the showbook
component, activatedRoute was utilized to extract and display the form data by retrieving the parameters.
RouterModule.forRoot([{path:'showbook/:id',component:showBookComponent}]) // in app module ts
this.activatedRoute.params.subscribe(params=>{
this.bookId = params['id']
})
Despite successfully displaying the form data upon submission, my current solution fails to save the data persistently. The requirement stipulates that the data must be saved until accessed via the showbook
component without relying on local storage implementation.