Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Ionic 2 Cookbook

You're reading from   Ionic 2 Cookbook The rich flavors of Ionic at your disposal

Arrow left icon
Product type Paperback
Published in Nov 2016
Publisher Packt
ISBN-13 9781786465962
Length 320 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Hoc Phan Hoc Phan
Author Profile Icon Hoc Phan
Hoc Phan
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Creating Our First App with Ionic 2 FREE CHAPTER 2. Adding Ionic 2 Components 3. Extending Ionic 2 with Angular 2 Building Blocks 4. Validating Forms and Making HTTP Requests 5. Adding Animation 6. User Authentication and Push Notification Using Ionic Cloud 7. Supporting Device Functionalities Using Ionic Native 8. Theming the App 9. Publishing the App for Different Platforms Index

Setting up a development environment

Before you create your first app, your environment must have the required components ready. These components ensure a smooth process of development, build and test. The default Ionic project folder is based on Cordova's. Therefore, you need the Ionic CLI to automatically add the correct platform (that is, iOS, Android, or Windows phone) and build the project. This will ensure all Cordova plugins are included properly. The tool has many options to run your app in the browser or simulator with live reload.

Getting ready

You need to install Ionic and its dependencies to get started. Ionic itself is just a collection of CSS styles, AngularJS components, and standard Cordova plugins. It's also a command-line tool to help manage all technologies, such as Cordova and Bower. The installation process will give you a command line to generate the initial code and build the app.

Ionic uses npm as the installer, which is included when installing Node.js. Please install the latest version of Node.js from https://nodejs.org/en/download/.

You will need to install Cordova, ios-sim (iOS Simulator) and Ionic:

$ npm install -g cordova ionic ios-sim

You can install all three components with this single command line instead of issuing three command lines separately. The -g parameter is to install the package globally (not just in the current directory).

For Linux and Mac, you may need to use the sudo command to allow system access, as shown:

$ sudo npm install -g cordova ionic ios-sim

The following are a few common options for an Integrated Development Environment (IDE):

  • Xcode for iOS
  • Android Studio for Android
  • Microsoft Visual Studio Code (VS Code)
  • Sublime Text (http://www.sublimetext.com/) for web development

All of these have a free license. You could code directly in Xcode or Android Studio but those are somewhat heavy-duty for web apps, especially when you have a lot of windows open and just need something simple to code. Sublime Text is free for non-commercial developers but you have to purchase a license if you are a commercial developer. Most frontend developers would prefer to use Sublime Text for coding HTML and JavaScript because it's very lightweight and comes with a well-supported developer community. Sublime Text has been around for a long time and is very user-friendly. However, there are many features in Ionic 2 that make Visual Studio Code very compelling. For example, it has the look and feel of a full IDE without being bulky. You could debug JavaScript directly inside VS Code as well as getting autocomplete (for example, IntelliSense). The following instructions cover both Sublime Text and VS Code, although the rest of this book will use VS Code.

How to do it…

VS Code works on Mac, Windows, and Linux. Here are the instructions

  1. Visit https://code.visualstudio.com.
  2. Download and install for your specific OS.
  3. Unzip the downloaded file.
  4. Drag the .app file into the Applications folder and drag it to Mac's Dock.
  5. Open Microsoft Visual Studio code.
  6. Press Ctrl + Shift + p to open command palette.
  7. Type shell command in command palette.
  8. Click on the Shell Command: Install 'code' command in PATH command to install the script to add Visual Studio Code in your terminal $PATH.
  9. Restart Visual Studio Code to take effect.
  10. Later on, you can just do code. (including the dot) directly from the Ionic project folder and VS Code will automatically open that folder as a project:

    Note

    Note that the following screenshots are done via Mac.

    How to do it…
  11. If you decide to use Sublime Text, you will need Package Control (https://packagecontrol.io/installation), which is similar to a Plugin Manager. Since Ionic uses Sass, it's optional to install the Sass Syntax Highlighting package.
  12. Navigate to Sublime Text | Preferences | Package Control:
    How to do it…
  13. Go to Package Control: Install Package. You could also just type the commands partially (that is, inst) and it will automatically select the right option:
    How to do it…
  14. Type Sass and the search results will show one option for TextMate & Sublime Text. Select that item to install:
    How to do it…

There's More…

There are tons of Sublime Text packages that you may want to use, such as HTML, JSHint, JSLint, Tag, and ColorPicker You can visit https://sublime.wbond.net/browse/popular for additional needs.

You have been reading a chapter from
Ionic 2 Cookbook - Second Edition
Published in: Nov 2016
Publisher: Packt
ISBN-13: 9781786465962
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image