TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ahmed elbarbary
NA
1.6k
278.3k
How to generate URL have partid based on part name from list
Dec 23 2019 3:01 PM
problem
How to generate URL have partid based on part name written on text input ?
I have input text on nvabar.Component.html write on it part name as following :
<mat-form-field
class
=
"example-full-width"
>
<input matInput placeholder=
"Enter name"
[(ngModel)]=
"partname"
>
</mat-form-field>
I need when write on text input Transistor part then I will search on list parts and get partid =2 .
then display it in URL as following :
localhost:4200/overview?partid=2
And I can access to Overview Component
navbar.component.ts
export
class
NavBarComponent
implements
OnInit {
public
parts = [
{
id: 1,
partname:
'hummer'
,
},
{
id: 2,
partname:
'Transistor'
,
},
{
id: 3,
partname:
'Air'
,
}
];
ngOnInit() {
}
Overview.Component.ts Compoent overview I need to access
export
class
OverviewComponent
implements
OnInit {
constructor() {
}
ngOnInit() {
//access partid value i will get from URL
}
app-routing.module.ts represent routing as following :
const
routes: Routes = [
{ path:
'overview'
, component: OverviewComponent },
{ path:
''
, redirectTo:
'/overview'
, pathMatch:
'full'
}
Reply
Answers (
1
)
How to get id of part name searched on textbox then add to u
How to get id from list when text input match or equal items