Skip to content

Instantly share code, notes, and snippets.

@mmaia
Created June 17, 2016 21:03
Show Gist options
  • Save mmaia/0e60b79f7e423d55d6f44bd54d82fa5e to your computer and use it in GitHub Desktop.
Save mmaia/0e60b79f7e423d55d6f44bd54d82fa5e to your computer and use it in GitHub Desktop.
Getting started ionic 1.x

Very quick start with Ionic, my personal notes.

This is my very quick start guide to ionic development, it contains my notes to quickly became up to speed with an app ready to start coding and basic ionic commands and issues for reference.

Install Android development Environment:

Install ionic & cordova:

  • npm install ionic -g
  • npm install cordova -g

Create Ionic Project and set platform:

  • ionic start ${appName} ${ionic_template}

    • ionic templates: blank, tabs or sidemenu
  • cordova platform add android

Useful command to check connected devices, in my current environment some times the device is not recognized: adb devices - it should show a device id if your device is connected via USB with your development machine. If the device id does not show the aforementioned ionic command (ie - ionic run) will not work properly.

Usefull ionic commands:

run in browser: ionic serve run in device: ionic run android -lc -i ${ionic_server_port}

When running your app in device for development if you find the error message: "There was a network error ${address}"

  1. Make sure the server and port you're running hte ionic command is accessible from the device, common mistakes are that you're not
  2. connected in the same internal network or the ip where you're running the dev. environment hence the ip of your development
  3. machine not accessible in some cases can also be due to a firewall, so check the connectivity from device to your development environment.
  4. Make sure you have installed the cordova whitelist plugin. In more recent versions it's required or you won't be able to
  5. access the server. cordova plugin add cordova-plugin-whitelist --save

When running on device use chrome inspector:

in google chrome address bar type: chrome://inspect

you'll see the connected device link.

File transfer

Install cordova plugins:

  • cordova plugin add cordova-plugin-file
  • cordova plugin add cordova-plugin-file-transfer

SQL Lite storage

In order to use sql lite storage (not html 5 local storage) install the following plugins:

Nice reference on how to use it.

Official reference on ngCordova site.

Note: If storing images to file system and trying to reference it during development when running the app with livereload it will give an error about permission to load the image and the image will not show. The error shows in browser when using chrome://inspect: with the message 'Not allowed to load local resource... file:///data ...' This is due to the fact that running livereload will actually point to the filesystem on your computer and not in the device. So in this case run the application without livereload i.e - ionic run android and it should then work properly.

Troubleshooting

If you have problems runing the app in the device check for connected devices using adb adb devices if your connected device is not on the list it will not work, then try to toggle development mode on and off on the device and check until device shows on the list or ionic run will not deploy the app to your device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment