Test Angular On Any Device
August 24, 2020 • Angular, Testing • Published By Josh • 1 minute read
When developing an Angular application, you will want to test it on devices other than the one you’re developing with. The Angular CLI provides an option to help with this.
Table of Contents
IP Address
The device you’re using for development has both an external and internal IP Address. We want the internal IP Address, which isn’t something that’s easily visible. Let’s find it.
On Windows:
- Type cmd in the Windows search and the Command prompt will appear.
- Type ipconfig.
- Look for the IPv4 Address and make note of the IP Address. We’ll need it in the next step.
Angular CLI Host Option
During development, you normally use ng serve to run your Angular application locally. You would visit your application at localhost:4200.
ng serve
We want to run the Angular application using your internal IP Address. Let’s use the Angular CLI host option replacing YOUR_IP_ADDRESS_HERE with your actual IP Address.
ng serve --host YOUR_IP_ADDRESS_HERE
You can now visit your application at YOUR_IP_ADDRESS:4200 from any device on your network!