Ionic Framework: A definitive 10,000 word guide

本文详细介绍Ionic框架,一种利用HTML5和AngularJS构建美观且交互性强的移动应用的方法。文章不仅覆盖了Ionic的基本介绍和安装指南,还通过一个计算器应用实例进行实战演示。

Ionic Framework: A definitive 10,000 word guide

原文:https://www.pluralsight.com/guides/front-end-javascript/ionic-framework-a-definitive-10-000-word-guide

Welcome! This definitive guide to the ionic framework -- an incredibly easy way to build beautiful and interactive mobile apps using HTML5 and AngularJS. We will help you understand the major aspects of the framework. We'll also be creating a running example of a calculator application throughout the tutorial.

In this first section, you'll learn:

  • An overview of the choices for making applications
  • Introduction to the Ionic framework
  • How to install Ionic on both Mac and Windows
  • How to use Ionic CLI to start an Ionic project
  • How to run an Ionic application

Introduction

85% of mobile time is spent in apps

You're bombarded with reports all  over  the  web  that users tend to spend way more time on their phones and especially in apps (rather than surfing the web using their phones) and you decided that it's time to learn how to make an app.

Up until fairly recently, if you wanted to make an app for (currently) two most popular mobile operating systems (iOS and Android) your only bet was to make the, so-called, native application. This meant you needed to make two versions of your application. Therefore, developers were opting either for iOS or Android, whereas big firms had two developing departments, one for each platform.

Nowadays, with the Ionic Framework you can create one application by using the skills you, as a web developer, already have and then deploy this one codebase as an app to both iOS and Android stores.

Ways you can make an app these days

There are actually 3 ways that you can make an application for mobile devices these days.

Native app

You can make an app specifically for iOS and Android by using their specific SDKs. If you want to build a native application for iOS you have to:

If you want to build a native application for Android you have to:

One of the pros of a native applications would be it's speed and direct access to a native API. A definite con of a native applications is that you need to build two (or more) applications, one for each desired platform.

Mobile website

Mobile website is actually a "normal" website that you visit with your browser on your phone, designed specifically to adapt to your phone's screen.

Developers used to make specific sites just for mobile browsers (on it's own domain; usually m.domain.com) but this proved to be hard to maintain. A practice called responsive website design  is used these days, where you basically have one HTML codebase, and you determine the look for specific devices (based on resolutions) by using the so-called media queries  in CSS.

A definite advantage of the mobile websites is that you can update them without waiting for the approval from Apple or Google. One of the disadvantages are that the mobile websites these days have way lower engagement than they used to, and that you can't use any of the additional phone features.

Hybrid app

A hybrid app is a mobile application, written with the same languages that you use when building websites, with the addition that it contains an isolated browser instance, called WebView, which runs this web application inside of a native app. Hybrid apps can access the mobile device and use the additional phone features like for example camera or GPS.

Definite advantage of the hybrid apps is that you can access the additional phone features via plugins and that you can do all the development with the same set of skills you use when developing "normal" web applications. One of the disadvantages is that, even though it's improving, the so-called Web View has it's limitations in terms of speed. Basically, you wouldn't use a hybrid approach if you want to build a 3D game.

1. What is Ionic and why it's so good

As I gave an answer on StackOverflow :

Disclaimer: This will sound like advertisement, so I have to say I'm in no way affiliated with Ionic, I just happen to like it so much that I'm sharing the love for it.

Ionic is so much more than “just” an UI framework. Ionic allows you to:

  • generate icons and splash screens for all devices and device sizes with a single command: ionic resources. This alone saves you at least a day of image preparing for various sizes.
  • instantly update your apps with code changes, even when running directly on your device with ionic run --livereload
  • build and test iOS and Android versions side-by-side and see changes instantly with ionic serve --lab
  • share your Ionic apps with clients, customers, and testers all around the world without ever going through the App Store with ionic share
  • easily access the full native functionality of the device using ngCordova (here you get to use any Cordova plugin) Also, Drifty  (the team behind the Ionic framework) is building a full-stack backend services and tools for your Ionic app like Deploy  (for deploying a new version without going through Apple review process! - this is huge!), Analytics Push notifications . Ionic CLI (command line interface) uses Cordova in the backend and allows you to build (directly using Ionic CLI) apps for iOS and Android (just by doing ionic build ios or ionic build android). Ionic uses Angular as a frontend framework so if you’re familiar with it, it will come as a bonus. They’re working closely with the Angular 2.0 team  too. All in all, I personally think Ionic framework has a bright future, so if nothing else – give it a try I bet you’ll like the ease of making an app with it.

Installing prerequisites for both Mac and Windows

We need to have Node.js  and Git  installed in order to install both Ionic and Cordova. If you're a web developer chances are that you already have these tools installed. If not, just visit the aforementioned websites and install them.

Installing Ionic

To install Ionic (both on Mac and Windows) you have to run the following command:

npm install ionic cordova -g

We had to install Cordova because Ionic uses it under the hood. We're using the -g flag to install the packages globally .

Using Ionic CLI

If you run ionic in your Terminal you will get a nice summary of all the commands that you can run using the ionic CLI, along with their short descriptions.

Starting a project with Ionic by using the existing templates

Ionic CLI allows us to start and initialize your project by using the ionic start command. If you just run ionic start appname the Ionic CLI will create a bootstrap application with all the needed parts in the appname folder, with the so-called blank template.

In our example, we will use the sidemenu template, so execute the following command:

ionic start Ionic_1stTutorial sidemenu

Running the Ionic application

First, change the directory to the name of the application you gave in the ionic start command (Ionic_1stTutorial in our case). There are few ways in which you can get your Ionic application running:

  • ionic serve - starts the app in a local web browser
  • ionic emulate android - starts the app in an emulator (in this example android is used; you can also use ios if you're on a Mac and have all the prerequisites installed)
  • ionic run android - starts the app on the actual device that's plugged into your computer
  • ionic build android - creates an .apk file which you can copy to your Android device and run it (this scenario doesn't work for iOS devices; you have to go through Xcode)

Run the following command in your Terminal:

ionic serve

You should get your local browser started up automatically, pointing to the address http://localhost:8100/#/app/playlists , with an output similar to the one on the image below:

image: http://i.imgur.com/Yvs4kzKl.jpg

Great thing about this is that you automatically have a live reload feature, which means that as soon as you change the code in your www folder, the application will reload automatically so that you don't have to do it manually.

If you like, you can get this project on Github .


Read more at https://www.pluralsight.com/guides/front-end-javascript/ionic-framework-a-definitive-10-000-word-guide#RhzKw8M4p8BGHVeW.99
内容概要:本文介绍了一个基于MATLAB实现的无人机三维路径规划项目,采用蚁群算法(ACO)与多层感知机(MLP)相结合的混合模型(ACO-MLP)。该模型通过三维环境离散化建模,利用ACO进行全局路径搜索,并引入MLP对环境特征进行自适应学习与启发因子优化,实现路径的动态调整与多目标优化。项目解决了高维空间建模、动态障碍规避、局部最优陷阱、算法实时性及多目标权衡等关键技术难题,结合并行计算与参数自适应机制,提升了路径规划的智能性、安全性和工程适用性。文中提供了详细的模型架构、核心算法流程及MATLAB代码示例,涵盖空间建模、信息素更新、MLP训练与融合优化等关键步骤。; 适合人群:具备一定MATLAB编程基础,熟悉智能优化算法与神经网络的高校学生、科研人员及从事无人机路径规划相关工作的工程师;适合从事智能无人系统、自动驾驶、机器人导航等领域的研究人员; 使用场景及目标:①应用于复杂三维环境下的无人机路径规划,如城市物流、灾害救援、军事侦察等场景;②实现飞行安全、能耗优化、路径平滑与实时避障等多目标协同优化;③为智能无人系统的自主决策与环境适应能力提供算法支持; 阅读建议:此资源结合理论模型与MATLAB实践,建议读者在理解ACO与MLP基本原理的基础上,结合代码示例进行仿真调试,重点关注ACO-MLP融合机制、多目标优化函数设计及参数自适应策略的实现,以深入掌握混合智能算法在工程中的应用方法。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值