ionic-framework

Topics related to ionic-framework:

Getting started with ionic-framework

Ionic is a framework for developing mobile applications with HTML, CSS, and JavaScript. Ionic applications run as native applications and have a native "look and feel".

Ionic is built on the AngularJS framework and provides a complete solution to design, build, and package mobile applications. Design is accomplished with a collection of template tools and a custom icon library. Ionic provides custom CSS/SASS components as well as Javascript UI Extensions. Ionic apps can be built, emulated, and packaged with their Command Line Interface (CLI).

Ionic templates are dynamic and responsive and adapt to their environment to provide a native "look and feel". This adaptation includes layout, style, and icons. Ionic makes independent platform customization available as well. Because Ionic apps use front end web technology, they can also be viewed in a browser for faster development.

Ionic apps are built on top of Apache Cordova by default. They have access to all Cordova Plugins which let you use native functionality, such as push notifications, camera, accelerometer, etc. Cordova apps work on multiple platforms and devices (phones, tablets, etc.) with very little extra effort. Cordova may be switched out with other cross-platform technologies such as trigger.io.

What's the difference between “ionic build” and “ionic prepare”?

Testing Ionic App in a Browser

Testing of native device features like Camera, Vibration and others, many of which are found in the documentation of Ionic Native, cannot be done in the browser. This is an inherent limitation of the fact that Cordova, the platform on which Ionic depends to be able to access native Android, iOS, and Windows Mobile APIs of a device, cannot run on the browser.

One can work around this issue by mocking the functionality of the native plugin.

Example

Here's an example on how to mock the Camera plugin:

Go ahead and create an optional folder in your project root folder.

cd src
mkdir mocks 
cd mocks 
touch camera-mock.ts 

Open camera-mock.ts and copy paste the following code:

export class CameraMock {
    getPicture(params) {
        return new Promise((resolve, reject) => {
            resolve("BASE_64_IMAGE_DATA");
        });
    }
}

Next open src/app.module.ts and import the mock class"

import { CameraMock } from "../mocks/camera-mock";

Then add it to module providers array:

@NgModule({
declarations: [
    MyApp,
    HomePage
],
imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
    MyApp,
    HomePage
],
providers: [
    StatusBar,
    SplashScreen,
    CameraMock,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}

Now you can use it in any component after importing it.

Ionic Backend Services (ionic.io)

Start Building Apps in Ionic

Deploy Ionic as a website

Connecting Ionic with any database

Run Ionic App on Emulator or on your Phone

How to use EcmaScript 6 features in Ionic?

Ionic - Analyze your app with jshint and gulp-jshint as part of your build process

Linting your ionic app before running has huge advantages. It will analyse code for potential errors and save you tremendous amount of time.

What is linting and how to install the required packages?

"Linting is the process of running a program that will analyse code for potential errors." - see What is "Linting"?

Your ionic app comes with a package.json file. Go to the root of you app in a Command Line/Terminal and install the following packages:

npm install jshint --save-dev
npm install jshint-stylish --save-dev
npm install gulp-jshint --save-dev

Ionicons

Ionic Cloud for Yeoman Ionic Projects

Ionic AngularJS extensions

Ionic offers a variety of Javascript AngularJS extensions for you to use. These extensions can be anything from normal form inputs to modal windows and makes coding your basic app a lot faster using these ready extensions.

Create Dialog in Ionic

The Ionic Popup service allows programmatically creating and showing popup windows that require the user to respond in order to continue.

Ionic CLI hooks

Introduction

Hooks are pieces of code that Cordova CLI executes at certain points in your Cordova/Ionic application build. Hooks can be used for example to manipulate files in our project, automatically add plugins into your application or as in the example above check for code errors in your files.

Note: It is highly recommended writing your hooks using Node.js so that they are cross-platform but you can write them also for example in Javascript.

Hook types

The following hook types are supported and execution order is quite self-explanatory according to the name.

after_build
after_compile
after_docs
after_emulate
after_platform_add
after_platform_rm
after_platform_ls
after_plugin_add
after_plugin_ls
after_plugin_rm
after_plugin_search
after_prepare
after_run
after_serve
before_build
before_compile
before_docs
before_emulate
before_platform_add
before_platform_rm
before_platform_ls
before_plugin_add
before_plugin_ls
before_plugin_rm
before_plugin_search
before_prepare
before_run
before_serve
pre_package/ <-- Applicable to Windows 8 and Windows Phone only. This hook is deprecated.

Ways to define hooks:

Hooks could be defined in project's config.xml using <hook> elements, for example:

<hook type="after_build" src="scripts/appAfterBuild.js" />

As a plugin developer you can define hook scripts using <hook> elements in a plugin.xml like this:

<hook type="after_build" src="scripts/afterBuild.js" />

before_plugin_install, after_plugin_install, before_plugin_uninstall plugin hooks will be fired exclusively for the plugin being installed/uninstalled.

Note: Placing hooks in the root/hooks directory is considered deprecated in favor of the hook elements in config.xml and plugin.xml. If you however use this approach remember to set execute rights to the files in the root/hooks folder.

Documentation for Cordova Hooks can be found here.

Ionic CSS components

Device camera and photo library access from Ionic application

Publishing your Ionic app

Ionic infinite scroll to show load items on demand (Already available data not by Http Request)