mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +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 {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
||||
|
||||
import {IonicConfig} from '../../config/config';
|
||||
import {ViewController} from '../view/view-controller';
|
||||
|
||||
|
||||
@ -28,18 +29,26 @@ class IonicRootComponent extends ViewController {
|
||||
compiler: Compiler,
|
||||
elementRef: ElementRef,
|
||||
loader: DynamicComponentLoader,
|
||||
injector: Injector
|
||||
parentInjector: Injector
|
||||
) {
|
||||
super(null, compiler, elementRef, loader, injector);
|
||||
|
||||
IonicRoot.component(this);
|
||||
let injector = parentInjector;
|
||||
let ComponentType = null;
|
||||
|
||||
if (appModules.length) {
|
||||
let appModule = appModules.shift();
|
||||
if (appModule.default) {
|
||||
this.push(appModule.default);
|
||||
ComponentType = appModules.shift();
|
||||
|
||||
injector = parentInjector.resolveAndCreateChild([
|
||||
bind(IonicConfig).toValue(ComponentType._config)
|
||||
]);
|
||||
}
|
||||
|
||||
super(null, compiler, elementRef, loader, injector);
|
||||
IonicRoot.component(this);
|
||||
|
||||
if (ComponentType) {
|
||||
this.push(ComponentType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,10 +64,21 @@ class PaneAnchor {
|
||||
|
||||
let appModules = [];
|
||||
|
||||
export function load(app) {
|
||||
if (app) {
|
||||
appModules.push(app);
|
||||
export function ionicBootstrap(ComponentType, config) {
|
||||
ComponentType._config = config || new IonicConfig();
|
||||
appModules.push(ComponentType);
|
||||
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 {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 {SecondPage} from './pages/second-page'
|
||||
@ -24,19 +24,22 @@ import {SecondPage} from './pages/second-page'
|
||||
'</ion-navbar>' +
|
||||
'<ion-content class="padding">' +
|
||||
'<p>First Page: {{ val }}</p>' +
|
||||
'<p><button (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 (click)="push()">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>' +
|
||||
'<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>',
|
||||
directives: [NavbarTemplate, Navbar, NavPush, Content]
|
||||
})
|
||||
export default class FirstPage {
|
||||
class FirstPage {
|
||||
constructor(
|
||||
nav: NavController
|
||||
nav: NavController,
|
||||
myConfig: IonicConfig
|
||||
) {
|
||||
|
||||
console.log('myConfig', myConfig);
|
||||
|
||||
// TODO: Shouldn't have to do this
|
||||
Router.setNavController(nav);
|
||||
|
||||
@ -98,3 +101,10 @@ export default class FirstPage {
|
||||
new Routable(FirstPage, {
|
||||
url: '/first-page'
|
||||
})
|
||||
|
||||
|
||||
export function main() {
|
||||
let myConfig = new IonicConfig();
|
||||
|
||||
ionicBootstrap(FirstPage, myConfig);
|
||||
}
|
||||
|
@ -2,4 +2,8 @@
|
||||
|
||||
export class IonicConfig {
|
||||
|
||||
constructor() {
|
||||
this.canWe = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
export * from 'ionic/config/component'
|
||||
export * from 'ionic/config/config'
|
||||
export * from 'ionic/components'
|
||||
export * from 'ionic/directives'
|
||||
export * from 'ionic/platform/platform'
|
||||
|
Reference in New Issue
Block a user