Getting started with ionic2
>=android 4.4, but you want run on
android 4.1 to
android 4.3 you have to use cross walk.
Installation or Setup
Since Ionic 2 is getting better and better every day, please always check the official documentation to keep track of the latest changes and improvements.
1. Installing Ionic 2
Like Ionic 1, you can use the Ionic CLI or GUI to quickly build and test apps right in the browser. It even has all the functionality to work with your Ionic 1 apps, so you won't need to change a thing!
To use Ionic 2 simply install ionic from npm:
If you get an EACCES error, follow the instructions here to give node the permissions it needs.
2. Creating Your First App
Once the CLI is installed, run the following command to start your first app:
The tabs template is used by default, but you can choose another template by passing in a flag. For example:
This will use the tutorial template.
To run your app, change into your projects directory and run
ionic serve -lc:
The -l activates the live reload of the page, the -c displays the console logs. If you're having issues building your app, make sure your package.json matches the one in the ionic2-app-base
You can play with your new app right there in the browser!
3. Building to a Device
You can also build your new app on a physical device or a device emulator. You will need Cordova to proceed.
To install Cordova, run:
Check out the iOS simulator docs for building iOS applications (NOTE: you cannot build to iOS devices or emulators on any operating system other than OSX), or the Genymotion docs to build an Android application.
Running on iOS device:
To build an iOS app, it is necessary for you to work on an OSX computer, because you will need the cocoa framework to be able to build for ios, if it's the case you will first need to add the platform to cordova by running the following command:
You will need Xcode to compile to an iOS device.
Finally, run your app with the following command:
Running on an Android device:
The steps for Android are almost identical. First, add the platform:
Then install the Android SDK which allows you to compile to an Android device. Although the Android SDK comes with an emulator, it's really slow. Genymotion is much faster. Once installed, simply run the following command:
And that's it! Congratulations on building your first Ionic 2 app!
Ionic has live reloading too. So if you want to develop your app and see changes taking place live on the emulator / device, you can do that by running the following commands:
Be careful, on iOS 9.2.2 the livereload doesn't work. If you want to work with livereload, edit the config.xml file by adding the following :
Then in the
<platform name="ios"> :
l stands for live-reload,
c for console logs, and
s for server logs.
This will allow you to see if there are any errors / warnings during execution.
Building for Windows
If you want to build your project for windows, you need to work on a windows computer. To start, install the windows platform to your ionic2 project by running the following command :
Then just run the following command :
To run in browser
for chrome browser inspect device.(type in address bar of chrome browser)