Ionic – Things I wish I knew out of the gate

Cordova is a gamechanger. Ionic framework (and ngCordova) are game changers to the Cordova scene. However, I have already learned two very painful lessons as a beginner into the bowels of Cordova-tech:

Avoid ionic-generator

While yeoman generators can be helpful, the ionic-generator simply imposes too much junk into your workflow. It shouldn’t be a surprise to those familiar with the generators.

“ionic run <platform> -lc”

Words cannot express how upset I was after much searching and suffering with launching emulators that livereload (‘-l’) comes OUT OF THE BOX with ionic-cli. Their ‘getting started’ documentation has nothing on this (as of this writing)!

Avoid ‘../’ (relative paths) in ANYTHING

Unless you want to mess around with building, you will end up biting yourself eventually when testing. For example, when you test with the ‘serve’ functionality, everything is served over HTTP.

You can end up biting yourself when you use relative paths in regards to css, js or angular template files, e.g.:

http://foo.bar.com/../file.js is the same as http://foo.bar.com/file.js
file://www_app/../file.js is NOT the same as file://file.js

The problems manifest themselves when you run on your device, the protocols turn into file:// and aren’t protected from the browser fail-safe’s.

$stateProvider: ‘cache: false’

$state.go('foo', {}, {reload: true}  does no good, you need to specify this extra property in your state definition in order to reload the controller.

 

Leave a Reply

Your email address will not be published. Required fields are marked *