Тёмный
No video :(

Angular read query string parameters 

kudvenkat
Подписаться 832 тыс.
Просмотров 28 тыс.
50% 1

In this video we will discuss, how to read query string parameters in Angular
Healthy diet is very important for both body and mind. We want to inspire you to cook and eat healthy. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking.
/ @aarvikitchen5572
To read query parameters we use ActivatedRoute service. We use this same service to read required and optional route parameters.
Text version of the video
csharp-video-tu...
Slides
csharp-video-tu...
Angular CRUD Tutorial
• Angular CRUD tutorial
Angular CRUD Tutorial Text Articles & Slides
csharp-video-tu...
All Dot Net and SQL Server Tutorials in English
www.youtube.co...
All Dot Net and SQL Server Tutorials in Arabic
/ kudvenkatarabic
Inject the ActivatedRoute service using the component class constructor
constructor(private _route: ActivatedRoute) { }
Depending on your project requirements, you can then use either the snapshot approach or the observable approach. We discussed the difference between these 2 approaches and when to use one over the other in Part 42 of this Angular CRUD tutorial.
Part 42 - Subscribe to angular route parameter changes
• Subscribe to angular r...
In Angular there are 3 types of parameters.
1. Required parameters
2. Optional parameters
3. Query parameters
When working with any of these parameters, the following properties and methods are very useful.
Member Description
has(name) Returns true if the parameter is present and false if not. Very useful to check for the existence of optional route and query parameters
get(name) Returns the parameter value as a string if present, or null if not present in the map. Returns the first element if the parameter value is an array of values
getAll(name) Returns a string array of the parameter value if found, or an empty array if the parameter is not present in the map. Use getAll when a single parameter could have multiple values
keys Returns a string array of all the parameters in the map
Please note : For required and optional route parameters, we use the paramMap property of the ActivatedRoute object and for Query Parameters, we use queryParamMap property.
Use the snapshot approach if the query params does not change during the lifetime of this component.
if (this._route.snapshot.queryParamMap.has('searchTerm')) {
this.searchTerm = this._route.snapshot.queryParamMap.get('searchTerm');
} else {
this.filteredEmployees = this.employees;
}
On the other hand, if you expect the query parameter value to change during the life time of this component, and if you want to react and execute some code in response to that change, then use the Observable approach.
this._route.queryParamMap.subscribe((queryParams) =] {
if (queryParams.has('searchTerm')) {
this.searchTerm = queryParams.get('searchTerm');
} else {
this.filteredEmployees = this.employees;
}
});

Опубликовано:

 

26 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 11   
@alexmartini8087
@alexmartini8087 4 года назад
I cannot thank you enough for this, this solved an issue that I was struggling with. Thank you!
@DarkGT
@DarkGT 6 лет назад
Hi Venkat (please respond) I truly feel in love with your SQL tutorial series, but I have a question- I want to make Inner Join with 2 Tables and to use that join with other table again as Join between Table and Join. I'm not aware how I can do that via single query or else. All help is greatly appreciated, you are one of the best online tutors I have seen on youtube, well done keep it up.
@deepanshukumar3943
@deepanshukumar3943 6 лет назад
Dark GT. Select a.country, b.state, c.city from country as co inner join state as st on co.cid=st.cid inner join city as ci on st.sid=ci.sid Hope u will understand..
@tender.branson
@tender.branson 6 лет назад
You can try to ask a question on stackoverflow.com.
@shahzaibriaz6552
@shahzaibriaz6552 6 лет назад
Shehzada Kudvenkat :)Awesome
@noponyexpectstheequestrian6350
Sir your voice on my phone sounds different from my computer
@muskaangupta7938
@muskaangupta7938 5 лет назад
hey, how do you get the id for manually created employee records?
@edosirait7891
@edosirait7891 4 года назад
please make it the same for angularJS to get the Param query case unreadable. Help
@jamesleo1498
@jamesleo1498 5 лет назад
this.activatedRoute.snapshot.queryParamMap.get('QuerystringKeyName') no longer works if I use HttpClientModule in my app.module.ts. Any thoughts?
@jamesleo1498
@jamesleo1498 5 лет назад
I solved it using the "observable approach" at the end of this video. Thanks for all of these tutorials over the years. You're great at explaining things!
@hp-qu5zi
@hp-qu5zi 6 лет назад
hi sir can you tell me about file upload and upload file preview...
Далее
Create observable from array
11:40
Просмотров 34 тыс.
Angular content projection
15:38
Просмотров 36 тыс.
Музыкальные пародии
00:28
Просмотров 19 тыс.
HOW DID SHE DECIDE TO DO THIS?!
00:27
Просмотров 7 млн
O'ZBEK VA TOJIKLAR ROSSIYADA TERAKT UYUSHTIRISHDI!
08:41
Liskov: The Liskov Substitution Principle
4:23
Просмотров 21 тыс.
We NEED To Talk About The War Within
24:51
Просмотров 237 тыс.
Angular query params
10:18
Просмотров 50 тыс.
GraphQL vs REST: Which is Better for APIs?
7:31
Просмотров 196 тыс.
Angular resolve guard
10:02
Просмотров 43 тыс.
Музыкальные пародии
00:28
Просмотров 19 тыс.