Coder Social home page Coder Social logo

ionic2course's Introduction

Ionic 2 Course

This course is (slightly) out of date.

The latest version of the code (for 3.13.2 release) can be downloaded at this link here.

This repository contains all the information you need to get your code up-to-date.

The course was built using the final beta for Ionic 2. There were a few key changes when Ionic 2 released the first RC which are documented here. All of the code for the course runs fine if you are using that final beta. The required tweaks are documented below for RC and beyond. Also, Pluralsight Plus subscribers can download a complete code sample of the course which has been updated for the latest Ionic 2 release.

Table of Contents

  1. Installation
  2. Project Structure
  3. Buttons
  4. Theme Colors
  5. Lifecycle Events
  6. Incorporating Third-Party Libraries - lodash
  7. Custom CSS
  8. Storage
  9. SQLite
  10. Mapping
  11. Miscellaneous

Installation

In the course, Ionic 2 was installed with:

npm install -g ionic@beta

As of the RC release, you can install Ionic 2 like this:

npm install -g ionic

If there is any doubt, see the Installing Ionic section of the Ionic 2 docs.

Project Structure

As of the RC release, the project structure is slightly different than what you'll see in the course. With @NgModule being introduced, the top level folder for your source code is now called src instead of app. All of the files related to the root app component (in conjunction with NgModule) are now stored in of sub-folder of src called app. The assets directory has also been moved into src as a sub-directory.

Important Note on NgModule:

Now that the RC release uses NgModule, each new page you create must be added the declarations and entryComponents properties in the app.module.ts file. For example:

@NgModule({
  declarations: [
    MyApp,
    GamePage,
    MapPage,
    MyTeamsPage,
    StandingsPage,
    TeamDetailPage,
    TeamHomePage,
    TeamsPage,
    TournamentsPage
  ],
  imports: [
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    GamePage,
    MapPage,
    MyTeamsPage,
    StandingsPage,
    TeamDetailPage,
    TeamHomePage,
    TeamsPage,
    TournamentsPage
  ],
  providers: []
})
export class AppModule {}

Buttons

Previously (as you see in the course), we could just refer to a button like this:

<button>Test</button>

Now we need to use ion-button attribute like this:

<button ion-button>Test</button>

The icon-only attribute is also required for "icon only" buttons.

Also, Floating Action Buttons (FAB) are now a distinct element. See FABs section of docs for details.

See New Behavior of Button section in Ionic 2 RC change log for more info.

Theme Colors

Previously we could add theme colors like "primary" adding the attribute directly like this:

<ion-tabs primary>

Now we use a color attribute. This makes dynamic scenarios easier.

<ion-tabs color="primary">

There are numerous components this applies to (e.g., buttons, badges, tabs, etc.).

See Component Colors in Ionic 2 RC0 change log for more info.

Lifecycle Events

A few Lifecycle Events were renamed. Mostly importantly, ionViewLoaded was renamed to ionViewDidLoad.

See Lifecycle Events Renamed section of Ionic 2 RC0 change log for more info.

Angular 2 HttpModule

Related to Angular 2 (not directly an Ionic change): In a previous version of Angular (i.e., the one used when recording the course), the import statement that was used was:

import { HTTP_PROVIDERS } from '@angular/http';

and specified in the list of providers.

This has been changed to:

import { HttpModule } from '@angular/http';

and specified in the list of imports.

Incorporate Lodash

The guidance for adding third-party libraries (like lodash) to your project has changed slightly. Here are the steps:

npm install lodash --save
npm install @types/lodash --save-dev

Import statement at top of files now now look like this:

import _ from 'lodash';

Custom CSS

For any components where you want custom styling, you should add a selector attribute to scope your CSS:

@Component({
  selector: 'page-about',
  templateUrl: 'about.html'
})

Also, you do not need to add an @import to the app.core.scss file any more.

See step #15 in the Steps to Upgrade section of the Ionic 2 RC change log.

Storage

In the RC release, storage was moved out of the core Ionic framework into a separate library called @ionic/storage. For the most part, the concepts are the same. The code samples in the course downloads have been updated for its usage.

Basic usage is shown in the Storage section of the Ionic 2 RC change log.

SQLite

The SqlStorage component was removed between the final Ionic 2 beta and the Ionic 2 RC release. Please see the sql-storage directory for an example of how the implement the user-settings.service.ts (shown in the course) using the Ionic Native SQLite plugin directly.

Mapping

Incorporating Angular 2 Google Maps (AGM) into an Ionic 2 app has changed slightly since the Ionic beta. Please see this blog post on how to incorporate AGM into the latest version of Ionic 2.

Additionally, here is a Github repository with the full working code just for Ionic 2 and AGM.

Miscellaneous

Item Divider

Side note: there is a bug in the RC release where the color attribute applied to an <ion-item-divider> doens't work. This issue has been identified and is being address by the Ionic team in issue #8376.

ionic2course's People

Contributors

smichelotti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ionic2course's Issues

JSON Firebase upload

Hello,
In the "Setting up your Backend" video that is in the "Working with HTTP and Lifecycle Events" you late how to up load the JSON file to Firebase. However, my console looks different from yours and does not feature the upload option that you used. I've searched through the documentation but all the information I find references how to upload using a script.
Any help or resource you could point me towards in order to resolve this would be greatly appreciated.
Jason

Ionic Native SQLite plugin example not present

Hi,
First of all I want to thank you for the high quality course you've made at Pluralsight.

In the SQLite section of the README.md file it's stated that the user-settings.service.ts file has been updated in order to show an example of native SQLite plugin manipulation. However, the plugin doesn't seem to be used inside the file.
Am I missing something?

update cli to 3.4.0,run error ,please help,tks!

updated:
``C:\Users\laura\TLGD>ionic serve
? The Ionic CLI has an update available (3.3.0 => 3.4.0)! Would you like to install it? Yes

npm install -g ionic@latest
✔ Running command - done!

[OK] Upgraded Ionic CLI to 3.4.0! �

Please re-run your command.

Note: You can downgrade to your old version by running: npm install -g [email protected]

C:\Users\laura\TLGD>ionic serve
? Local plugin @ionic/cli-plugin-cordova has an update available (1.3.0 => 1.4.0)! Would you like to install it? Yes

npm install --save-dev --save-exact @ionic/cli-plugin-cordova@latest
✔ Running command - done!
[OK] Upgraded @ionic/cli-plugin-cordova to 1.4.0! �
? Local plugin @ionic/cli-plugin-ionic-angular has an update available (1.3.0 => 1.3.1)! Would you like to install it? Yes
npm install --save-dev --save-exact @ionic/cli-plugin-ionic-angular@latest
✔ Running command - done!
[OK] Upgraded @ionic/cli-plugin-ionic-angular to 1.3.1! �
[INFO] Starting app-scripts server: --port 8100 --p 8100 --livereload-port 35729 --r 35729 --address 0.0.0.0 - Ctrl+C to
cancel
[20:50:30] watch started ...

Error information:
TypeError: Cannot read property 'name' of undefined
at Object.eval [as updateRenderer] (ng:///AppModule/MyApp.ngfactory.js:77:45)
at Object.debugUpdateRenderer [as updateRenderer] (http://localhost:8100/build/main.js:13069:21)
at checkAndUpdateView (http://localhost:8100/build/main.js:12448:14)
at callViewAction (http://localhost:8100/build/main.js:12758:17)
at execEmbeddedViewsAction (http://localhost:8100/build/main.js:12730:17)
at checkAndUpdateView (http://localhost:8100/build/main.js:12444:5)
at callViewAction (http://localhost:8100/build/main.js:12758:17)
at execComponentViewsAction (http://localhost:8100/build/main.js:12704:13)
at checkAndUpdateView (http://localhost:8100/build/main.js:12449:5)
at callViewAction (http://localhost:8100/build/main.js:12758:17)
Ionic Framework: 3.2.1
Ionic App Scripts: 1.3.7
Angular Core: 4.1.0
Angular Compiler CLI: 4.1.0
Node: 6.10.3
OS Platform: Windows 10
Navigator Platform: Win32
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.104 Safari/537.36

Getting all items from local storage

This is from Ionic Local Storage session. The getting all items from local storage has changed.

let items = [];

this.storage.forEach(value => {
    items.push(JSON.parse(value));
})

return items.length ? items: null;

However, the forEach will return a Promise, so items will be empty and cannot be returned. How can you resolve this?

Thanks,

Ion-Title on Team Home not changing

Hello,

I'm having an issue where the team name being displayed in the ion-title is not updating on team-home.

Specifically this happens if I click on Team A go to the team detail, choose a specific game, and click on their opponent from the game page, instead of showing "Team B" at the top of the Team Home view, it still shows "Team A" However, all the other data loaded on to the Team Home page at that time is that of Team B. I compared my code on team-home.ts/html and game.ts/html to that of the finished app in your repo and they look nearly identitical.

Error on building app ionic 2 rc1

I'm trying to build the app to test on my phone and no matter what I do, it keeps getting this error.
I've already tried to reinstall node, ionic, cordova, typescript an everything else.

$ ionic2course-rc1 # ionic run android

Running 'run:before' npm script before run

> ionic-hello-world@ build /home/user/pluralsight/ionic2/ionic2course-rc1
> ionic-app-scripts build

[00:22:18]  ionic-app-scripts 0.0.39 
[00:22:18]  build prod started ... 
[00:22:18]  clean started ... 
[00:22:18]  clean finished in 6 ms 
[00:22:18]  copy started ... 
[00:22:18]  ngc started ... 
[00:22:19]  copy finished in 198 ms 
[00:22:19]  lint started ... 
[00:22:24]  lint finished in 4.91 s 
[00:22:25]  Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider 
            replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in 
            /home/user/pluralsight/ionic2/ionic2course-rc1/.tmp/app/app.module.ts, resolving 
            symbol AppModule in 
            /home/user/pluralsight/ionic2/ionic2course-rc1/.tmp/app/app.module.ts 
[00:22:25]  ngc failed 
[00:22:25]  ionic-app-script task: "build" 
[00:22:25]  Error: Error 

npm ERR! Linux 4.4.0-42-generic
npm ERR! argv "/home/user/.nvm/versions/node/v6.9.1/bin/node" "/home/user/.nvm/versions/node/v6.9.1/bin/npm" "run" "build"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! ionic-hello-world@ build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ionic-hello-world@ build script 'ionic-app-scripts build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ionic-hello-world package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ionic-app-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ionic-hello-world
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls ionic-hello-world
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/user/pluralsight/ionic2/ionic2course-rc1/npm-debug.log
Caught exception:
 undefined 

Mind letting us know? https://github.com/driftyco/ionic-cli/issues

Can you help me @smichelotti ?

Ionic 2 Testing Configuration

I am looking to setup ionic 2 test suite. but i am unable to set it up.
I am aware of angular 2 having simple test configuration.
Can you please guide me in this regard.

TS2349:Cannot invoke an expression whose type lacks a call signature.

I got the following error while trying to build the new source:

Error:(36, 7) TS2349:Cannot invoke an expression whose type lacks a call signature. Type '(<TResult1 = {}, TResult2 = never>(onfulfilled?: (value: {}) => TResult1 | PromiseLike,...' has no compatible call signatures.

In reference to line 36 of of app.module.ts :

      this.userSettings.initStorage().then(() => {
        this.rootPage = MyTeamsPage;
        this.refreshFavorites();
        this.events.subscribe('favorites:changed', () => this.refreshFavorites());
      });

It looks like similar errors from the VScode project are being set to ignore. Is it safe to ignore this?


TypeScript: 3.10.10
Ionic Framework: 2.0.0
Ionic Native: 2.4.1
Ionic App Scripts: 1.0.0
Angular Core: 2.2.1
Angular Compiler CLI: 2.2.1
Node: 6.10.2
OS Platform: Windows 7
Navigator Platform: Win32
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36

Google maps guides are out of date.

Angular Google Maps has been updated. Import is now:
import {AgmCoreModule} from "@agm/core";
and html elements are:
<agm-map id="map" [latitude]="map.lat" [longitude]="map.lng" [zoom]="map.zoom"> <agm-marker id="main-marker" [latitude]="map.lat" [longitude]="map.lng"></agm-marker> </agm-map>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.