Sunday, July 30, 2017

How to update Ionic 2 cli and libraries

The old version of Ionic had the straightforward update tool, it was enough just to run ionic lib update and it was just done. But this method no more works With Ionic 2.
Learn how to update the Ionic 2 cli and libraries.
First of all, we’ll need to upgrade the cli, it’s easy:
Than we need to get the newer package versions (with already resolved dependencies) with a simple command:
It will return list like the following:
Now you’ll need to open your package.json file (in the project root) with your favorite editor and change the package versions as in the ‘Latest’ column of output.
Than everything you’ll need to do, is just to run:

Saturday, June 24, 2017

Using Storage in Ionic 3

Ionic’s LocalStorage is now called simply Storage in Ionic 3 and behind the scenes Storage decides the best method to store the data. On mobile phones for example, SQLite is the preferred storage method. IndexedDB, WebSQL or localstorage is used in browsers for Progressive Web Apps.

InstallationFirst, install the SQLite Cordova plugin with this command:$ cordova plugin add cordova-sqlite-storage --save

Then install Storage. You can skip this step if you’re using a version or Ionic 3 greater than RC0, because Storage is now included automatically: $ npm install --save @ionic/storage

Importing + InjectingImport it in the appropriate module, the app root module for example:Module: app.module.tsimport { Storage } from '@ionic/storage'; @NgModule({ ... providers: [ Storage ] }) @NgModule({ ... providers: [ Storage ]})@NgModule({ ... providers: [ Storage ]})@NgModule({ ... providers: [ Storage ]})

Then inject it in the components that need it:Component: team.tsimport { Storage } from '@ionic/storage'; export class TeamPage {  constructor(public navCtrl: NavController, public storage: Storage) { }

UsageNow you’re ready to start using Storage’s set, get and remove methods. Let’s use a simple example where we have three methods, one that sets a team as a favorite, one that removes the team from the favorites and one that checks if a team is a favorite:Component: team.ts

fav() {`team ${ this.teamId }`, this.teamName);
this.favorite = true; }
removeFav() {`team ${ this.teamId }`); this.favorite = false; }
isFav() {'team ' + this.teamId).then((value) => { value ? this.favorite = true : this.favorite = false

}).catch(() => this.favorite = false); }In that example, the isFav method can be used in the ionViewWillEnter page lifecycle hook to determine if a team is already a favorite. 


Monday, May 8, 2017

Send Email Directly to a Folder (Label) in Gmail

Here are the steps to set this up:
1. Log in to your gMail account

2. Create a new label. Call it whatever you like. Note: use an underscore instead of a space when naming your labels. This label will be listed on the left-hand side of your window.
3. Now Create a filter by clicking on Settings, then on Filters
4. Place your cursor in the input box labeled To: and type in where gmail_username is your GMail username. For instance Then click next.
5. Now check Apply the label and choose Neat_Stuff or whatever you named your label.
6. Check Skip the inbox to automatically send the message to that label instead of your main inbox.
7. Finally Click Create filter and you’re ready to go!

Optional Step:
8. I found that by adding the email address to my personal contact on my phone has made this even easier. Go to your specific contact in the contacts on your phone and add an additional email address to that contact that looks like this:
changing the default to whatever your username and label are. That way when you find something you want to forward to your email, you can start typing your email address in the To: field and the tweaked email address will show up as an option.

Monday, March 27, 2017


The first thing you probably want to do is make sure Ionic-CLI and Cordova are up to date:
npm install -g cordova ionic@beta
This line will also install both frameworks from scratch if you don’t have previous installations.
For the next step, you need to be inside a project folder.


Warning: Backup your project before you do this next step.
I bet a lot of you have a previous experience with Ionic v1. Back then, Ionic v1 was updated using this line:
ionic lib update
This solution no longer works. Ionic v1 used bower under the hood; Ionic v2 is moving away from this approach.
New solution requires us to know current Ionic v2 version. To find this information, open an official Ionic Framework npm page, look at the right side, you’ll find it there:
Ionic 2 npm page
This value should be a current Ionic 2 Framework version.
Let’s get back to our local project. Find a local version of package.json, search for a dependencies section, and update ionic-framework parameter value.
If Ionic 2 is still in alpha status, prior to doing next step, you may want to remove the ionic-framework folder from node_modules folder.
Update your project using this line:
npm install
While manually updating Ionic 2 settings, you can’t know if a newly updated version also requires additional/new dependencies. If any dependency changed since the last installation, you’d receive an error looking like this:
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v4.2.3
npm ERR! npm  v2.14.7
npm ERR! peerinvalid The package angular2@2.0.0-alpha.52 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer ionic-framework@2.0.0-alpha.49 wants angular2@2.0.0-beta.0
npm ERR! Please include the following file with any support request:
npm ERR!     E:\Programiranje\Ionic2\Ionic2FirstApp\npm-debug.log
As you can see, my current Ionic 2 version requires newer Angular2 version; update package.json accordingly.
Do this step over and over until you find a stable combination.
Finally, let’s check if everything is working as it should:
ionic serve