Your First Ionic App: Angular
The great thing about Ionic is that with one codebase, you can build for any platform using just HTML, CSS, and JavaScript. Follow along as we learn the fundamentals of Ionic app development by creating a realistic app step by step.
Here’s the finished app running on all 3 platforms:
Looking for the previous version of this guide that covered Ionic 4 and Cordova? See here.
What We'll Build
We'll create a Photo Gallery app that offers the ability to take photos with your device's camera, display them in a grid, and store them permanently on the device.
Highlights include:
- One Angular-based codebase that runs on the web, iOS, and Android using Ionic Framework UI components.
- Deployed as a native iOS and Android mobile app using Capacitor, Ionic's official native app runtime.
- Photo Gallery functionality powered by the Capacitor Camera, Filesystem, and Preferences APIs.
Find the complete app code referenced in this guide on GitHub.
Download Required Tools
Download and install these right away to ensure an optimal Ionic development experience:
- Node.js for interacting with the Ionic ecosystem. Download the LTS version here.
- A code editor for... writing code! We are fans of Visual Studio Code.
- Command-line interface/terminal (CLI):
- Windows users: for the best Ionic experience, we recommend the built-in command line (cmd) or the Powershell CLI, running in Administrator mode.
- Mac/Linux users, virtually any terminal will work.
Install Ionic Tooling
Run the following in the command line terminal to install the Ionic CLI (ionic
), native-run
, used to run native binaries on devices and simulators/emulators, and cordova-res
, used to generate native app icons and splash screens:
To open a terminal in Visual Studio Code, go to Terminal -> New Terminal.
npm install -g @ionic/cli native-run cordova-res
The -g
option means install globally. When packages are installed globally, EACCES
permission errors can occur.
Consider setting up npm to operate globally without elevated permissions. See Resolving Permission Errors for more information.
Create an App
Next, create an Ionic Angular app that uses the “Tabs” starter template and adds Capacitor for native functionality:
ionic start photo-gallery tabs --type=angular --capacitor
This starter project comes complete with three pre-built pages and best practices for Ionic development. With common building blocks already in place, we can add more features easily!
Next, change into the app folder:
cd photo-gallery
Next we'll need to install the necessary Capacitor plugins to make the app's native functionality work:
npm install @capacitor/camera @capacitor/preferences @capacitor/filesystem