Introduction To Ionic
Introduction To Ionic
Ionic Framework
CSS Components
JavaScript Elements
Setting up Ionic CLI
Ionic Ecosystem
The course is a mix of concepts, practice exercises and intermediate assessments. Hope you
enjoy the course!
What is Ionic?
Ionic is a AngularJS and Cordova based open-source frameworkthatallows developers to
build cross platform applications for allmobile platforms(Android/iOS/ Windows).
Ionic apps are built using web technologies like HTML, CSSandJavaScript,and can be
started using Node.js CLI.
Ionic Documentation
IonicFramework.com has excellent documentation that developers can put to use
immediately.
We will go through few most commonly used CSS, Javascript tags and features in this
course. And the rest, we are sure you will be able to explore, experiement and learn!
Ionic Utilities
Ionic comes with handful of utility classes to help you quickly style your design.
Color Classes
Ionicons
Padding Elements
Ionic purposely does not use words like red or blue. Instead has colors which represent an
emotion or generic theme.
Ionic Icons
Ionic comes with its own free and open-sourced icon font - Ionicons, with over 500 icons to
choose from.
Simply add icon and the Ionicon classname for the icon to show. Icon can be easily looked up
on the Ionicons.com.
Padding
Many components in Ionic purposely have both padding and margin reset set to zero.
Developers can easily control padding and margins throughout the app.
The padding utility classes add a default 10px between the outer box of the element and its
inner content.
CSS Components
Ionic comes with a robust set of components which give the app a native look and feel.
These components offer almost all elements that mobile application needs. Components
default styling can be easily overridden as required.
In this module,we will learn about few of the many CSS Components available by default with
Ionic.
Adding a Header:
Adding a Footer:
Responsive Grid
Responsive classes can be used to turn each column in a row into its own row at certain
breakpoints. This is useful when columns do not fit well in the available area.
Classes for defining when the columns should break into stack of rows:
Example:
Usage:
<ion-checkbox ng-model="isChecked">
Checkbox Label
</ion-checkbox>
<ion-radio ng-model="choice" ng-value="'A'">
Radio A Label
</ion-radio>
<ion-toggle ng-model="option1Mode" toggle-class="toggle-calm">
Option1 Mode
</ion-toggle>
Assertive options can be highlighted in red and made obvious. Here is a sample Action Sheet
which opens on click of a button.
HTML:
<body>
<div ng-app="ionicApp">
<div ng-controller="AppController">
<ion-header-bar class="bar-positive">
<h1 class="title">Action Sheet</h1>
</ion-header-bar>
<ion-content class="padding">
<button class="button" ng-click="showAction()">
Show Actionsheet
</button>
</ion-content>
</div>
</div>
</body>
Javascript:
angular.module('ionicApp', ['ionic'])
.controller('AppController', function($scope, $ionicActionSheet){
$scope.showAction=function(){
$ionicActionSheet.show({
titleText: 'ActionSheet Example',
buttons: [
{text:'<i class="icon ion-share"></i>Share Contact'},
{text:'<i class="icon ion-arrow-move"></i>Move Contact to Cloud'},
],
destructiveText: 'Delete Contact',
cancelText:'Cancel',
cancel: function(){
console.log('CANCELLED');
},
buttonClicked: function(index){
console.log('BUTTON CLICKED', index);
return true;
},
destructiveButtonClicked: function(){
console.log('DESTRUCT');
return true;
}
});
};
});
A container element for side menu(s) and the main content, allows the left and / or right side
menu to be toggled by dragging the main content area side to side.
Usage:
<ion-side-menus>
<ion-side-menu side="left">
</ion-side-menu>
<ion-side-menu-content>
<!-- Main content, usually <ion-nav-view> -->
</ion-side-menu-content>
<ion-side-menu side="right">
</ion-side-menu>
</ion-side-menus>
function ContentController($scope, $ionicSideMenuDelegate) {
$scope.toggleLeft = function() {
$ionicSideMenuDelegate.toggleLeft();
}; }
Usage - HTML:
<ion-content scroll="false">
<ion-slides options="options" slider="data.slider">
<ion-slide-page>
<div class="box blue"><h1>BLUE</h1></div>
</ion-slide-page>
<ion-slide-page>
<div class="box yellow"><h1>YELLOW</h1></div>
</ion-slide-page>
<ion-slide-page>
<div class="box pink"><h1>PINK</h1></div>
</ion-slide-page>
</ion-slides>
</ion-content>
Usage- Javascript:
$scope.options = {
loop: false, effect: 'fade', speed: 500,
}
Loading - An overlay that can be used to indicate activity while blocking user interaction.
Spinner - Provides a variety of animated spinners to let users know the app is
processing/thinking/waiting/chillin’ out.
In a port in your IP
In your local host
Hosting the app in IP, allows users to test from other devices by invoking the server IP
address with the port.
Once the command is executed, it will automatically open the app in the browser.
Starts Live Reload of app for file changes, helping monitor changes in the file system.
Go inside the TestApp directory and type the emulator command to launch the app.
Once the app is launched, click on different tabs to see if the app is working perfectly.
Note: Optionally, device name can be provided in this command. If not provided, it will
automatically open the app in the latest device iOS/Android Device.
Ionic Resources
Ionic Resources is a really cool tool for automatically generating all the splash screens and
icons for your apps.
Save icons, splashscreens to resources folder of Ionic Project, add platform and run the
resource tool using:
ionic resources
This single command, resizes and crops all images to accommodate different screen
sizes and saves them to resources/android or resources/ios folders.
Ionic View
Ionic View makes it easy to share your Ionic apps with other developers in the organization
and testers around the world, without complicated Beta provisioning.
Ionic Market
Ionic Framework is light and performant, with most essential components and mobile UI
paradigms. If you are looking for anything beyond this, Ionic Market is the place you need to
go.
Ionic Market facilitates an open exchange of Ionic starter apps, themes, and plugins to
jumpstart app development.
Ionic Creator
Ionic Creator is a Rapid Mobile App Builder with simple draganddrop components, that can
help any one to build an App at jet speed.
Going beyond prototying, you can add your own code, export clean, standards compliant
Ionic projects, and even iOS and Android builds ready to submit to the App Stores.
ngCordova
A collection of over 70 native AngularJS extensions on top of the Cordova API that
makesit easy to build, test, and deploy Cordova mobile apps with AngularJS.
Camera
Touch ID
Authorization
Push Notification
Geolocation
Progress Indicator
Ionic Framework
Using CSS Components
Using JavaScript Elements
Setting up Ionic CLI
Ionic Ecosystem
This is just a beginning and we encourage you to experiment and explore further to discover a
lot of other cool features that come with IONIC!
QUIZ:
1. Which of the following files contains all required JS files for Ionic and Angular? IONIC.BUNDLE.MIN.JS
2. Which of the following files has the ionic styles? IONIC.CSS
3. Which of the following statement is not true about the IONIC framework? IT IS BUILD ON TOP......
4. Which of the following folders contains icons in Ionic? FONTS
5. Which of the following is not a in-built Ionic template? NAVIGATION
6. Which of the following includes device APIs that allow accessing native device features like camera or
maps? CORDOVA
7. Which of the following classes can be used to group a set of items in a List? ITEM DIVIDER
8. Which of the following classes can be used to create a button that occupies the entire width of the
screen? BUTTON BLOCK
9. Which of the following classes can be used to create margin of certain number pixels around the list
items? LIST-INSET
10. Which of the following tags display a button with rounded corners? BOTH
11. Adding which of the following classes to the content, makes space for the header. HAS HEADER
12. Which of the following classes defines the footer? BAR-FOOTER
13. Ionic Grid system is responsive by default. T
14. Which of the following components uses "CSS Flexible Box Layout"? GRIDS
15. Cards can contain ____. ALL
16. Which of the following CSS components are best to create a News App that displays a picture, caption
with short description? Cards
17. In a responsive Grid, which class, breaks the row of columns, when the window size is smaller than
portrait tablet? responsive-md
18. Which CSS component is ideal for creating top navigation for a mobile app? TABS
19. Which of the following directives can be used to enable the "pull to refresh" functionality? ION
REFRESHER
20. What is the ionic directive that can be used for creating a tab bar? ION TABS
21. Which of the following services can be used to trigger an Action Sheet? $ionicActionSheet
22. Which of the following directives can help in using Ionic custom Scroll View, or the built in overflow
scrolling of the browse? ION CONTENT
23. Which of the following is a content pane that can go over the user’s main view temporarily?
MODAL
24. Which of the following is a slide-up pane that lets the user choose from a set of options? action sheet
25. Which of the following interaction modes can be enabled by using ionList and ionItem directives?
ALL
26. Which of the following components is a multi-page container where each page can be swiped or
dragged between? ION SLIDES
27. Which of the following directives can help in using Ionic custom Scroll View, or the built in overflow
scrolling of the browse? ion content
28. CLI is based on _____. CORDOVA
29. In Ionic CLI, which of the follow commands can be used to automatically monitor changes in the file
system? IONIC SERVE
30. CLI is an extension of _________. NODE.JS
31. What is the command for running an app in IOS emulator? IONIC EMULATE IOS
32. Which of the following is the place to check for community contributed IONIC Components? Ionic
Market
33. Which tool can be used to create icons and splash screens for all supported devices Ionic
Resources
34. Components in Ionic by default have both padding of: 5PX