Mobile first! Wijmo 5 + Ionic Framework: Hello World !, Wijmoionic
In this tutorial, we use Wijmo 5 and Ionic Framework to implement a Mobile project: Hello World.
What is Ionic?
Ionic is an HTML5 framework that is free and open-source. It is used to help generate hybird mobile Apps (hybrid mobile Apps ).
Ionic contains three parts:
- CSS style: Used to render Web pages so that pages are closer to Native apps ).
- AngularJS: Ionic uses AngularJs extension commands as the core framework library, and AngularJs accelerates the development process.
- Apache Cordova: Ionic uses Apache Cordova to compile it into a mobile App, and provides the ngCordova library-Cordova API library extended by AngularJs.
The Ionic framework is still in beta stage (by the end of this article, the latest version: v1.0.0-beta.12 "kryton-koala" · MIT Licensed ), the current version supports iOS6 + and Android 4.1 +, and supports Windows devices in a planned manner. There is no version support plan for older devices.
Required
This tutorial uses the following environment. Please prepare in advance.
- Git
- Node. js
- Bower
- Apache Cordova
In this tutorial, we use Chrome for development and debugging. At the same time, you can use other browsers for debugging on Android and IOS devices.
To configure the system environment, see the Cordova Platform Guide and follow the wizard.
Quick Start
Based on NodeJs installed in the above system environment, we first install Ionic CLI.
The following command line code for Windows, Linux, and Mac is used for installation:
Windows
Npm install -- g ionic
Linux and Mac
Sudo npm install -- g ionic
Run the following command to create a project:
Ionic start ExpenseTracker blank & cd ExpenseTracker
The above command uses the empty Ionic template "blank" and creates an Ionic project named "ExpenseTracker". After the project is created successfully, we enter the newly created ExpenseTracker directory. Then we run the Ionic command to start the Web site.
Ionic serve
This command starts the Web service and uses the default browser to start the page.
Any modifications made when the Web service is started, refresh the browser page without restarting the Web service, which is very convenient for debugging.
The following page is displayed:
To stop the service, you can end the service in the command line.
Next, add the source code of Wijmo 5 to the project we created. The source code of Wijmo5 is as follows. Create a Wijmo folder under the www/lib folder of the project, and copy the three Dist folders controls, interop, and styles under Wijmo source code to the newly created Wijmo folder. The www/lib directory in the project folder contains the library files that the app depends on.
Source code path after Wijmo 5 download:
Iconic directory browsing:
After the file directory structure is configured, we can use Inonic and Wijmo 5. In the wwwdirectory, create an index.html file, edit it with the IDE (Visual Studio, Web Storm) You are used to, and add jQuery and Wijmo references:
<!DOCTYPE html>The AngularJs file is not directly referenced in the index.html file because Ionic (ionic. bundle. js file) it already contains AngularJs and its dependencies, such as UI-Router, so it does not need to be referenced directly. Use Wijmo 5
Next, add the Wijmo 5 control to the Index. HTML file. First, add the Wijmo module dependency to the www/js/app. js file --'Wj'.
The complete code of app. js is as follows:
angular.module('starter', ['ionic', 'wj']).run(function($ionicPlatform) { $ionicPlatform.ready(function() { // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard // for form inputs) if(window.cordova && window.cordova.plugins.Keyboard) { cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); } if(window.StatusBar) { StatusBar.styleDefault(); } });})
In app. js, the ionic and wijmo modules have been introduced. You can directly use the custom AngularJs command of Wijmo 5 below.
In the index.html file<body>
The AngularJS commands of three icons are introduced in the element:<ion-pane>
,<ion-header-bar>
, And<ion-content>。
<Ion-pane>: This command is a container used to fill the content.
<Ion-header-bar>: This command is used to add a header to the page.
<Ion-content>: This command creates a content area and replaces the default browser with the custom rolling view of Ionic.
In<Ion-content>,We add<Wj-input-number (Wijmo InputNumber control), the complete code is as follows:
<ion-pane> <ion-header-bar class="bar-stable">
Run the project. You can see that the Wijmo InputNumber control has been added to the page. The default value is 1, the maximum value is 5, the minimum value is-5, and the growth step is 1.
Summary
In this article, we created an Ionic project and added the Wijmo 5 InputNumber control to complete a Hello World!
Project compressed package