mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
BS from main()
This commit is contained in:
@ -13,6 +13,7 @@ import {bind} from 'angular2/di';
|
|||||||
import {Injectable} from 'angular2/src/di/decorators';
|
import {Injectable} from 'angular2/src/di/decorators';
|
||||||
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
||||||
|
|
||||||
|
import {IonicConfig} from '../../config/config';
|
||||||
import {ViewController} from '../view/view-controller';
|
import {ViewController} from '../view/view-controller';
|
||||||
|
|
||||||
|
|
||||||
@ -28,18 +29,26 @@ class IonicRootComponent extends ViewController {
|
|||||||
compiler: Compiler,
|
compiler: Compiler,
|
||||||
elementRef: ElementRef,
|
elementRef: ElementRef,
|
||||||
loader: DynamicComponentLoader,
|
loader: DynamicComponentLoader,
|
||||||
injector: Injector
|
parentInjector: Injector
|
||||||
) {
|
) {
|
||||||
super(null, compiler, elementRef, loader, injector);
|
let injector = parentInjector;
|
||||||
|
let ComponentType = null;
|
||||||
IonicRoot.component(this);
|
|
||||||
|
|
||||||
if (appModules.length) {
|
if (appModules.length) {
|
||||||
let appModule = appModules.shift();
|
ComponentType = appModules.shift();
|
||||||
if (appModule.default) {
|
|
||||||
this.push(appModule.default);
|
injector = parentInjector.resolveAndCreateChild([
|
||||||
|
bind(IonicConfig).toValue(ComponentType._config)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super(null, compiler, elementRef, loader, injector);
|
||||||
|
IonicRoot.component(this);
|
||||||
|
|
||||||
|
if (ComponentType) {
|
||||||
|
this.push(ComponentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,11 +64,22 @@ class PaneAnchor {
|
|||||||
|
|
||||||
let appModules = [];
|
let appModules = [];
|
||||||
|
|
||||||
export function load(app) {
|
export function ionicBootstrap(ComponentType, config) {
|
||||||
if (app) {
|
ComponentType._config = config || new IonicConfig();
|
||||||
appModules.push(app);
|
appModules.push(ComponentType);
|
||||||
bootstrap(IonicRootComponent);
|
bootstrap(IonicRootComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function load(app) {
|
||||||
|
if (!app) {
|
||||||
|
console.error('Invalid app module');
|
||||||
|
|
||||||
|
} else if (!app.main) {
|
||||||
|
console.error('App module missing main()');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
app.main();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {bootstrap, QueryList} from 'angular2/angular2'
|
|
||||||
import {Component, Directive, onInit} from 'angular2/src/core/annotations_impl/annotations';
|
import {Component, Directive, onInit} from 'angular2/src/core/annotations_impl/annotations';
|
||||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||||
|
|
||||||
|
import {ionicBootstrap, IonicConfig} from 'ionic/ionic';
|
||||||
import {Nav, NavPush, NavPop, NavParams, Routable, Router, NavController, NavbarTemplate, Navbar, NavPush, Content} from 'ionic/ionic';
|
import {Nav, NavPush, NavPop, NavParams, Routable, Router, NavController, NavbarTemplate, Navbar, NavPush, Content} from 'ionic/ionic';
|
||||||
|
|
||||||
import {SecondPage} from './pages/second-page'
|
import {SecondPage} from './pages/second-page'
|
||||||
@ -24,19 +24,22 @@ import {SecondPage} from './pages/second-page'
|
|||||||
'</ion-navbar>' +
|
'</ion-navbar>' +
|
||||||
'<ion-content class="padding">' +
|
'<ion-content class="padding">' +
|
||||||
'<p>First Page: {{ val }}</p>' +
|
'<p>First Page: {{ val }}</p>' +
|
||||||
'<p><button (click)="push()">Push (Go to 2nd)</button></p>' +
|
'<p><button primary (click)="push()">Push (Go to 2nd)</button></p>' +
|
||||||
'<p><button [push-data]="pushData" [nav-push]="pushPage">Push w/ nav-push (Go to 2nd)</button></p>' +
|
'<p><button primary [push-data]="pushData" [nav-push]="pushPage">Push w/ nav-push (Go to 2nd)</button></p>' +
|
||||||
'<icon class="ion-ios-arrow-back"></icon>' +
|
'<icon class="ion-ios-arrow-back"></icon>' +
|
||||||
'<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>' +
|
'<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>' +
|
||||||
'<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>' +
|
'<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>' +
|
||||||
'</ion-content>',
|
'</ion-content>',
|
||||||
directives: [NavbarTemplate, Navbar, NavPush, Content]
|
directives: [NavbarTemplate, Navbar, NavPush, Content]
|
||||||
})
|
})
|
||||||
export default class FirstPage {
|
class FirstPage {
|
||||||
constructor(
|
constructor(
|
||||||
nav: NavController
|
nav: NavController,
|
||||||
|
myConfig: IonicConfig
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
console.log('myConfig', myConfig);
|
||||||
|
|
||||||
// TODO: Shouldn't have to do this
|
// TODO: Shouldn't have to do this
|
||||||
Router.setNavController(nav);
|
Router.setNavController(nav);
|
||||||
|
|
||||||
@ -98,3 +101,10 @@ export default class FirstPage {
|
|||||||
new Routable(FirstPage, {
|
new Routable(FirstPage, {
|
||||||
url: '/first-page'
|
url: '/first-page'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
export function main() {
|
||||||
|
let myConfig = new IonicConfig();
|
||||||
|
|
||||||
|
ionicBootstrap(FirstPage, myConfig);
|
||||||
|
}
|
||||||
|
@ -2,4 +2,8 @@
|
|||||||
|
|
||||||
export class IonicConfig {
|
export class IonicConfig {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.canWe = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
export * from 'ionic/config/component'
|
export * from 'ionic/config/component'
|
||||||
|
export * from 'ionic/config/config'
|
||||||
export * from 'ionic/components'
|
export * from 'ionic/components'
|
||||||
export * from 'ionic/directives'
|
export * from 'ionic/directives'
|
||||||
export * from 'ionic/platform/platform'
|
export * from 'ionic/platform/platform'
|
||||||
|
Reference in New Issue
Block a user