Upgrading to Ionic 3 APPENDIX D. Angular 4

Similar documents
Angular 4 Syllabus. Module 1: Introduction. Module 2: AngularJS to Angular 4. Module 3: Introduction to Typescript

Lab 1 - Introduction to Angular

Integrating Angular with ASP.NET Core RESTful Services. Dan Wahlin

One Framework. Angular

Cross-Platform Mobile-Entwicklung mit dem Ionic Framework

ANGULAR 2.X,4.X + TYPESRCIPT by Sindhu

Setting up an Angular 4 MEAN Stack (Tutorial)

By the end of this Angular 6 tutorial, you'll learn by building a real world example application:

IN4MATX 133: User Interface Software

Chapter 1 - Development Setup of Angular

Chapter 1 - Model Driven Forms

Before proceeding with this tutorial, you should have a basic understanding of HTML, CSS, JavaScript, TypeScript, and Document Object Model (DOM).

Mobile App Development

INTRODUCTION TO IONIC 2

Introduction to. Angular. Prof. Dr.-Ing. Thomas Wiedemann.

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

Sample Copy. Not For Distribution.

This document contains brief summaries of the enhancements and issues resolved in FIMS version

ANGULAR2 OVERVIEW. The Big Picture. Getting Started. Modules and Components. Declarative Template Syntax. Forms

PHP + ANGULAR4 CURRICULUM 6 WEEKS

Ignite UI Release Notes

Angular 4 Training Course Content

Stencil: The Time for Vanilla Web Components has Arrived

Advantages: simple, quick to get started, perfect for simple forms, don t need to know how form model objects work

Decoupled Drupal with Angular

IONIC. The Missing SDK For Hybrid Apps. Mike

Frontend Web Development with Angular. CC BY-NC-ND Carrot & Company GmbH

The Oracle APEX Community at-a-glance:

User Guide Product Design Version 1.7

About me. Routing into the Sunset with Angular. Manfred Steyer SOFTWAREarchitekt.at Trainer & Consultant Focus: Angular Google Developer Expert (GDE)

BI Office. Release Notes 6.41

Demystifying Angular 2. SPAs for the Web of Tomorrow

Frontend UI Training. Whats App :

Surface Documentation

SBCUSD IT Training Program. Google Drive. Document Management and File Collaboration

Angular 2 Programming

Introduction to Release 5.1 HTML5

Sequence 8.2 Release Notes. Date: 13 th November 2016

Learn to Build Awesome Apps with Angular 2

Upgrading. the Upgrading to Microsoft Dynamics GP 2015 Hot Topic.

IN4MATX 133: User Interface Software

GIT TUTORIAL. Creative Software Architectures for Collaborative Projects CS 130 Donald J. Patterson

SOU Banner 9 Navigation Guide

Matrix 6.12 Browser Compatibility

AngularJS Fundamentals

CSS for Page Layout Robert K. Moniot 1

Software Architecture Documentation for the JRC MYGEOSS app for Invasive Species project

SBCUSD IT Applications Training & Support. Google Drive Document Management and File Collaboration

Ignite UI Release Notes

International Research Journal of Engineering and Technology (IRJET) e-issn: Volume: 05 Issue: 05 May p-issn:

RELEASE NOTES. December 3, To sign up for Release Notes notifications, please go to:

Astra Schedule User Guide Scheduler

ag.el Documentation Release 0.45 Wilfred Hughes

Order Management Defaulting Rules reduce the amount of data input required when entering orders or returns.

1.9.7 Release Notes May 2014

Ten interesting features of Google s Angular Project

WELCOME TO JQUERY PROGRAMMING LANGUAGE ONLINE TUTORIAL

THE ROAD TO ANGULAR 2.0

Hands on Angular Framework

Introduction...2. Application Navigator...3

CLIQ Web Manager. User Manual. The global leader in door opening solutions V 6.1

AngulAr 4 Pocket Primer

Extender 2016 Release Notes

Tyler Dashboard. User Guide Version 6.3. For more information, visit

Varargs Training & Software Development Centre Private Limited, Module: HTML5, CSS3 & JavaScript

Documentation External Synchronization FirstSpirit

Lesson4:CreatinganInterfaceandChecklistService

Problem With Ldap Error Code 17 Undefined Attribute Type Remaining Name

Network Rail Brand Hub USER GUIDE

Introduction to C++/CLI 3. What C++/CLI can do for you 6 The rationale behind the new syntax Hello World in C++/CLI 13

Review of HTML. Chapter Pearson. Fundamentals of Web Development. Randy Connolly and Ricardo Hoar

Version CTF Import. Using Excel to view the Check 99 report. Jim Haywood Capita SIMS

LoanPro Software Staging Release

"Charting the Course... Comprehensive Angular. Course Summary

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

Oracle Financial Consolidation and Close Cloud. What s New in the August Update (17.08)

Course Outline. ProTech Professional Technical Services, Inc. Comprehensive Angular 7 Course Summary. Description

User Guide. RACER Date 09/29/17

Learn to Build Awesome Apps with Angular 2

NEW WEBMASTER HTML & CSS FOR BEGINNERS COURSE SYNOPSIS

National Health Service

release notes effective version 10.3 ( )

Xcode Encountered An Internal Logic Error >>>CLICK HERE<<<

Mac/Windows Chrome 31+ (recommended browser at PSU), Firefox 24, and Safari 6+ ipad ios 6+ Android tablets Chrome 31+

Now we are porting. (a short time ago in a company not so far away) Mihails Strasuns

CPM: A Declarative Package Manager with Semantic Versioning

QPack Release Notes. SP Reviewing the changes between SP to November 2012

News in RSA-RTE 10.1 updated for sprint Mattias Mohlin, January 2018

Working with Pages... 9 Edit a Page... 9 Add a Page... 9 Delete a Page Approve a Page... 10

NetAdvantage for ASP.NET Release Notes

BI Office. Release Notes 6.40

PHP WITH ANGULAR CURRICULUM. What you will Be Able to Achieve During This Course

2. Phonebook P Import phonebook P Export phonebook P Buddy List P Your Status P Buddy List Settings P.

GOBENCH IQ Release v

Automation with Meraki Provisioning API

This section of the release notes is reserved for notable changes and new features since the prior version.

Front End. Presentation Layer. UI (User Interface) User <==> Data access layer

Seagate Crystal Reports 8 and Hyperion Essbase

Advance Mobile& Web Application development using Angular and Native Script

PEGACUIS71V1 pegasystems

Transcription:

APPENDIX D Upgrading to Ionic 3 As this book was being printed, Ionic received another major upgrade. Unlike the quantum leap from Ionic 1 to Ionic 2, this upgrade is less dramatic. With that being said, there are some adjustments we need to make in each of our three sample applications to have them run using Ionic 3. Before we get to those changes, let s look at what the upgrade entailed First, let s answer the question of why jump from Ionic 3 from Ionic 2, just a short time after its release? The team at Ionic recently switched over to using Semantic Versioning (Semver) for Ionic releases. Those guidelines describe calculating the version number as: MAJOR.MINOR.PATCH. MAJOR version when you make incompatible API changes, MINOR version when you add functionality in a backwards-compatible manner, and PATCH version when you make backwards-compatible bug fixes. One of the main changes in Ionic 3, was adding support for Angular 4.0.0. While this is a welcomed updated, that version of Angular does had some incompatible APIs changes with its previous version, Angular 2 (there is no Angular 3). As such, Ionic also had to follow suit and label this as a major upgrade. Angular 4 So, what do we get with this upgrade to Angular 4? The biggest benefit is our applications should now be smaller and faster. I suspect over the coming releases of Angular and Ionic that this will continue to improve. 265

TypeScript Updates Ionic 2 required you to use TypeScript 2.0.9. Now, with Ionic 3, you can use either TypeScript 2.1 or 2.2. The main benefit of this upgrade is improved build time and type checking in your application. IonicPage Decorator The Ionic team has introduced a new decorator, @IonicPage. This decorator will allow you to define your deep links easier, and allow for the use of lazy loading of your application s pages. Lazy Loading With traditional Ionic 2 applications, all the components were loaded during the app s initialization. Now, with lazy loading we can define the initial set of components (pages) we will want to have initially available. The rest of the applications pages, will be loaded as needed. This capability is not enabled by default, as it is still under some active development. Components Changes There were three key changes to some components with this release. First, the old Ionic Grid system has been removed from Ionic 3. You must use the col-x syntax when defining the column width. Second, the color selector on native text elements (headers, paragraphs, spans, etc.) has been removed. You now need to include the ion-text attribute to enable the use of the color directive. Third, the Slides component s properties and functions have been updated. Here is a list of those changes: Slides input options have been removed. Please use the input properties instead. Slide event ionwillchange has been removed, please use ionslidewill Change instead. Slide event iondidchange has been removed, please use ionslidedidchange instead. Slide event iondrag has been removed, please use ionslidedrag instead. Slides getslider() method has been removed, please use the instance of ionslides. For more details about any of these updates, see the changelog at https://github.com/ driftyco/ionic/blob/master/changelog.md. 266 Appendix D: Upgrading to Ionic 3

Upgrading the Ionic2Do application Since this application is generated for one of the default templates, there is little we need to do to make it compatible with Ionic 3. In the app.module.ts file we need to include the HttpModule: import { HttpModule } from '@angular/http'; Next, we need to include this within our imports array: BrowserModule, HttpModule, IonicModule.forRoot(MyApp) That is all that we should have to do to make Ionic2Do run using Ionic 3. Upgrading the IonicParks application Unlike the first application, this application is started using a template hosted on our GitHub account. One change that had to occur in the template is the addition of the BrowserModule to our imports. We also still need to include the HttpModule as well. In the app.module.ts file add both of these modules: import { BrowserModule } from '@angular/platform-browser'; import { HttpModule } from '@angular/http'; and include them within our imports array: BrowserModule, HttpModule, IonicModule.forRoot(MyApp) When we use the Ionic CLI s generator to create our Park Details page, it is currently producing some incorrect syntax. If you look in the park-details directory, you will now see four files listened. There is now a park-details.module.ts file. This module file is used as part of the new lazy loading system. It is in this file that we need to fix the code. The generator incorrectly references the IonicModule, when it should reference IonicPageModule instead. Here is the correct code: import { NgModule } from '@angular/core'; import { IonicPageModule } from 'ionic-angular'; import { ParkDetails } from './park-details'; @NgModule({ declarations: [ ParkDetails,, Upgrading to Ionic 3 267

IonicPageModule.forChild(ParkDetails),, exports: [ ParkDetails }) export class ParkDetailsModule {} We suspect that this issue will be addressed shortly. Another benefit of this new page module is that we no longer have to import the page(s) that we might navigate to. Instead, we can simply refer to them by name. In Ionic 2, we would pass the new page s component reference to the Nav Controller. For example, here is the function used in the park-list.ts file to navigate to the details page: import { ParkDetailsPage } from '../park-details/park-details'; goparkdetails(theparkdata) { this.navctrl.push(parkdetailspage, { parkdata: theparkdata }); } With the new module system, we don t need to have that import included and our function becomes: goparkdetails(theparkdata) { this.navctrl.push("parkdetails", { parkdata: theparkdata }); } The string that we pass into the Nav Controller is defined with that new parkdetails.module.ts file. The Nav Controller will still accept either input type, so if you don t want to switch over, you don t have to. Updating the Ionic Weather Application Like, the Ionic Parks application, this application is generated using a template hosted on our GitHub account. One change that had to occur in the template is the addition of the BrowserModule to our imports. We also still need to include the HttpModule as well. In the app.module.ts file add both of these modules: import { BrowserModule } from '@angular/platform-browser'; import { HttpModule } from '@angular/http'; and include them within our imports array: BrowserModule, HttpModule, IonicModule.forRoot(MyApp) 268 Appendix D: Upgrading to Ionic 3

In updating this application, we did run into one real issue. The data binding to the weather data would now throw an error. We have not fully resolved what the change is within Angular 4 that is triggering it. The issue is in referencing an index in an array. Here is a sample of the template that uses that syntax: {{daily.data[0.temperaturemax number:'.0-0'}} <br> {{daily.data[0.temperaturemin number:'.0-0'}} Specifically, the daily.data[0, fails to work. As a simple workaround, we will assign each index value to their own variable. In weather.ts file, replace the variable definition of with daily: any = {}; day1: any = {}; day2: any = {}; day3: any = {}; Also, change the instances of with this.daily = this.theweather.daily; this.day1 = this.theweather.daily.data[0; this.day2 = this.theweather.daily.data[1; this.day3 = this.theweather.daily.data[2; In the weather.html file, we will need to update the template reference as well to use these new variables: <ion-row> {{day1.temperaturemax number:'.0-0'}} <br> {{day1.temperaturemin number:'.0-0'}} {{day2.temperaturemax number:'.0-0'}} <br> {{day2.temperaturemin number:'.0-0'}} {{day3.temperaturemax number:'.0-0'}} <br> {{day3.temperaturemin number:'.0-0'}} </ion-row> We will also need to adjust the variable that the ngif refers to in the <ion-gird> <ion-grid *ngif="day1!= undefined"> Upgrading to Ionic 3 269

In addition, we now need to reset the day1 variable within our constructor in the weather.ts file, otherwise, we will have floating degree symbols while the weather data is being refreshed. let loc: CurrentLoc = this.navparams.get('geoloc'); this.day1 = undefined; Updating the Page References The other major change with this application is the new page naming syntax. Instead of referring to WeatherPage and LocationsPage throughout the application, we simply use Weather and Locations. You will need to adjust the app.module.ts, app.component.ts, locations.ts, and locations-service.ts files with this new syntax. Conclusion That should cover all the changes to our three applications so they can compile and run using Ionic 3. 270 Appendix D: Upgrading to Ionic 3