|
2 | 2 |
|
3 | 3 | > Click :star:if you like the project. Pull Request are highly appreciated. Follow me [@SudheerJonna](https://twitter.com/SudheerJonna) for technical updates.
|
4 | 4 |
|
| 5 | +--- |
| 6 | + |
| 7 | +<div align="center"> |
| 8 | + <p> |
| 9 | + <a href="https://www.fullstack.cafe/?utm_source=github&utm_medium=sud"> |
| 10 | + <b>Having Tech Interview?</b> |
| 11 | + <br> 3600 Tech Interview Questions. <b>Answered</b>. |
| 12 | + <br> |
| 13 | + <div> |
| 14 | + <img src="https://user-images.githubusercontent.com/13550565/76382460-cc784d80-6393-11ea-8837-2b89265ac853.png" width="260" alt="FullStack.Cafe"> |
| 15 | + </div> |
| 16 | + </a> |
| 17 | + <sub><i>Proudly supporting Angular Interview Questions</i></sub> |
| 18 | + </p> |
| 19 | +</div> |
| 20 | + |
| 21 | +--- |
| 22 | + |
5 | 23 | ## Downloading PDF/Epub formats
|
6 | 24 |
|
7 | 25 | You can download the PDF and Epub version of this repository from the latest run on the [actions tab](https://github.com/sudheerj/angular-interview-questions/actions).
|
@@ -280,7 +298,7 @@ You can download the PDF and Epub version of this repository from the latest run
|
280 | 298 | |268| [How do you optimize the performance of async validators?](#how-do-you-optimize-the-performance-of-async-validators)|
|
281 | 299 | |269| [How to set ngFor and ngIf on the same element?](#how-to-set-ngfor-and-ngif-on-the-same-element)|
|
282 | 300 | |270| [What is host property in css?](#what-is-host-property-in-css)|
|
283 |
| -|271| [](#)| |
| 301 | +|271| [How do you get the current route?](#how-do-you-get-the-current-route)| |
284 | 302 | |272| [](#)|
|
285 | 303 | |273| [](#)|
|
286 | 304 | |274| [](#)|
|
@@ -4509,4 +4527,22 @@ You can download the PDF and Epub version of this repository from the latest run
|
4509 | 4527 | padding: 20px;
|
4510 | 4528 | }
|
4511 | 4529 | ```
|
4512 |
| - **[⬆ Back to Top](#table-of-contents)** |
| 4530 | + **[⬆ Back to Top](#table-of-contents)** |
| 4531 | +
|
| 4532 | +271. ### How do you get the current route? |
| 4533 | + In Angular, there is an `url` property of router package to get the current route. You need to follow the below few steps, |
| 4534 | +
|
| 4535 | + 1. Import Router from @angular/router |
| 4536 | + ```js |
| 4537 | + import { Router } from '@angular/router'; |
| 4538 | + ``` |
| 4539 | + 2. Inject router inside constructor |
| 4540 | + ```js |
| 4541 | + constructor(private router: Router ) { |
| 4542 | +
|
| 4543 | + } |
| 4544 | + ``` |
| 4545 | + 3. Access url parameter |
| 4546 | + ```js |
| 4547 | + console.log(this.router.url); // /routename |
| 4548 | + ``` |
0 commit comments