<!DOCTYPE html>
<html>
<head>
<title>Ionic 2 QuickStart</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="https://npmcdn.com/core-js/client/shim.min.js"></script>
<script src="https://npmcdn.com/zone.js@0.6.12?main=browser"></script>
<script src="https://npmcdn.com/reflect-metadata@0.1.3"></script>
<script src="https://npmcdn.com/systemjs@0.19.27/dist/system.src.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script src="https://npmcdn.com/ionic-angular@2.0.0-beta.8/bundles/ionic.system.js"></script>
<link href="https://npmcdn.com/ionic-angular@2.0.0-beta.8/bundles/ionic.css" rel="stylesheet">
<style>
/*
Temporary hack to get icons to work in Plunker
ionic.css references fonts with querystring version (i.e. ?v=3.0.0-alpha.3)
NPM CDN fails to load: https://npmcdn.com/ionic-angular@2.0.0-beta.7/fonts/ionicons.woff2?v=3.0.0-alpha.3
So load fonts manually...
*/
@font-face {
font-family: "Ionicons";
src: url("https://npmcdn.com/ionic-angular@2.0.0-beta.7/fonts/ionicons.woff2") format("woff2"), url("https://npmcdn.com/ionic-angular@2.0.0-beta.7/fonts/ionicons.woff") format("woff"), url("https://npmcdn.com/ionic-angular@2.0.0-beta.7/fonts/ionicons.ttf") format("truetype");
font-weight: normal;
font-style: normal;
}
</style>
<script>
System.import('app').catch(function(err) {
console.error(err);
});
</script>
</head>
<!-- 3. Display the application -->
<body>
<ion-app></ion-app>
</body>
</html>
<!--
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
-->
Basic Ionic 2 starter template. Ionic 2 code based on [Starter Blank](https://github.com/driftyco/ionic2-starter-blank) and the systemjs.config.js and tsconfig.json are based on the Angular 2 Example - QuickStart Plunker.
More Ionic 2 demos on my [Plunker page](https://plnkr.co/users/cklanac)
/**
* PLUNKER VERSION (based on systemjs.config.js in angular.io)
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function(global) {
var ngVer = '@2.0.0-rc.1'; // lock in the angular package version; do not let it float to current!
//map tells the System loader where to look for things
var map = {
'app': 'app',
'@angular': 'https://npmcdn.com/@angular', // sufficient if we didn't pin the version
'angular2-in-memory-web-api': 'https://npmcdn.com/angular2-in-memory-web-api', // get latest
'rxjs': 'https://npmcdn.com/rxjs@5.0.0-beta.6',
'ts': 'https://npmcdn.com/plugin-typescript@4.0.10/lib/plugin.js',
'typescript': 'https://npmcdn.com/typescript@1.8.10/lib/typescript.js'
};
//packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'app.ts', defaultExtension: 'ts' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' }
};
var ngPackageNames = [
'common',
'compiler',
'core',
'http',
'platform-browser',
'platform-browser-dynamic',
'router',
'router-deprecated',
'upgrade'
];
// Add map entries for each angular package
// only because we're pinning the version with `ngVer`.
ngPackageNames.forEach(function(pkgName) {
map['@angular/'+pkgName] = 'https://npmcdn.com/@angular/' + pkgName + ngVer;
});
// Add package entries for angular packages
ngPackageNames.forEach(function(pkgName) {
// Bundled (~40 requests):
packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
// Individual files (~300 requests):
//packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
});
var config = {
// DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
transpiler: 'ts',
typescriptOptions: {
tsconfig: true
},
meta: {
'typescript': {
"exports": "ts"
}
},
map: map,
packages: packages
};
System.config(config);
})(this);
/*
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
*/
import {Component} from "@angular/core";
import {Platform, ionicBootstrap} from 'ionic-angular/index';
// import {StatusBar} from 'ionic-native';
import {HomePage} from 'app/pages/home/home.ts';
// Note the @Component and ionicBootstrap (at the bottom)
@Component({
template: '<ion-nav [root]="rootPage"></ion-nav>'
})
export class MyApp {
rootPage: any = HomePage;
constructor(platform: Platform) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
// StatusBar.styleDefault();
});
}
}
ionicBootstrap(MyApp);
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
import {Component} from "@angular/core";
import {ListItem} from "../../components/items-list";
@Component({
templateUrl: 'app/pages/home/home.html',
directives: [ListItem]
})
export class HomePage {
items: Array<string>;
constructor() {
this.items = [];
for(let i = 0; i < 1000; i++) {
this.items.push(`item - ${i}`);
}
}
}
<ion-navbar *navbar>
<ion-title>
<ion-icon name="home" item-left></ion-icon> Home
</ion-title>
</ion-navbar>
<ion-content class="home">
<ion-card>
<ion-card-header>
Card Header
</ion-card-header>
<ion-card-content>
Hello World
</ion-card-content>
</ion-card>
<ion-list [virtualScroll]="items">
<list-item *virtualItem="let item" [item]="item"></list-item>
<!-- <ion-item *virtualItem="let item" item="item">{{item}}</ion-item> -->
</ion-list>
</ion-content>
import {Component, Input} from '@angular/core';
@Component({
selector: 'list-item',
templateUrl: 'app/components/items-list.html'
})
export class ListItem {
@Input() item: string;
constructor() {
}
}
<ion-item>
Item: {{item}}
</ion-item>