Asking Angular Developers to create a mobile app is wrong. Here's a better way.
Deploying your Angular application on mobile via NativeScript
2 min read
What is NativeScript?
Why should I use NativeScript?
Writing mobile apps can require some resources that you may not have readily available. Whether it's the hardware required to develop mobile applications, or simply the programming languages used to write mobile applications. If you do not know Objective C or Swift, then you cannot write iOS mobile apps without taking the time to learn. The same goes for Android, which requires Java.
The development environment for NativeScript relies on Node.JS and the NativeScript CLI.
- NativeScript CLI:
npm install -g nativescript
Install the "NativeScript Playground" App on your mobile device for testing:
iOS also requires that you install the NativeScript Preview application.
Creating a new NativeScript app via Template
The NativeScript CLI provides templates to use in order to get started if you do not have an existing application.
ns create client
- Creates mobile app from a template.
- Scan the QR Code displayed in the terminal using the "NativeScript Playground" app on your mobile device.
The mobile app should be running on your mobile device!
Leveraging NativeScript in an existing Angular application
If you have an existing Angular application and decide that you would like to create a mobile application, this section is for you.
Your first step is to add NativeScript via a schematic, which will convert your app over to a code-sharing structure. You can do this by running the following:
ng add @nativescript/schematics
Verify you can still run your Angular application, and once verified run
ns preview to preview your mobile application.
We've now successfully created an Angular application that will run on your mobile device!