mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
update to alpha42
This commit is contained in:
@ -4,7 +4,7 @@ import {Page} from 'ionic/ionic';
|
|||||||
|
|
||||||
@Page({
|
@Page({
|
||||||
templateUrl: 'forms/forms.html',
|
templateUrl: 'forms/forms.html',
|
||||||
bindings: [FormBuilder]
|
providers: [FormBuilder]
|
||||||
})
|
})
|
||||||
export class FormsPage {
|
export class FormsPage {
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ export class FormsPage {
|
|||||||
console.log(event);
|
console.log(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Page({
|
@Page({
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {Compiler, ElementRef, Injector, bind, NgZone, DynamicComponentLoader, AppViewManager} from 'angular2/angular2';
|
import {Compiler, ElementRef, Injector, provide, NgZone, DynamicComponentLoader, AppViewManager} from 'angular2/angular2';
|
||||||
|
|
||||||
import {Ion} from '../ion';
|
import {Ion} from '../ion';
|
||||||
import {makeComponent} from '../../config/decorators';
|
import {makeComponent} from '../../config/decorators';
|
||||||
@ -37,29 +37,16 @@ import {raf} from '../../util/dom';
|
|||||||
*
|
*
|
||||||
* Behind the scenes, when Ionic instantiates a new NavController, it creates an
|
* Behind the scenes, when Ionic instantiates a new NavController, it creates an
|
||||||
* injector with NavController bound to that instance (usually either a Nav or
|
* injector with NavController bound to that instance (usually either a Nav or
|
||||||
* Tab) and adds the injector to its own bindings. For more information on
|
* Tab) and adds the injector to its own providers. For more information on
|
||||||
* binding and dependency injection, see [Binding and DI]().
|
* providers and dependency injection, see [Providers and DI]().
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* // class NavController
|
* // class NavController
|
||||||
* //"this" is either Nav or Tab, both extend NavController
|
* this.providers = Injector.resolve([
|
||||||
* this.bindings = Injector.resolve([
|
* provide(NavController, {useValue: this})
|
||||||
* bind(NavController).toValue(this)
|
|
||||||
* ]);
|
* ]);
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* That way you don't need to worry about getting a hold of the proper
|
|
||||||
* NavController for views that may be used in either a Tab or a Nav:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* class MyPage {
|
|
||||||
* constructor(@Optional() tab: Tab, @Optional() nav: Nav) {
|
|
||||||
* // Unhhhhh so much typinggggg
|
|
||||||
* // What if we are in a nav that is in a tab, or vice versa, so these both resolve?
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* Instead, you can inject NavController and know that it is the correct
|
* Instead, you can inject NavController and know that it is the correct
|
||||||
* navigation controller for most situations (for more advanced situations, see
|
* navigation controller for most situations (for more advanced situations, see
|
||||||
* [Menu](../../Menu/Menu/) and [Tab](../../Tab/Tab/)).
|
* [Menu](../../Menu/Menu/) and [Tab](../../Tab/Tab/)).
|
||||||
@ -146,8 +133,8 @@ export class NavController extends Ion {
|
|||||||
this._ids = -1;
|
this._ids = -1;
|
||||||
|
|
||||||
// build a new injector for child ViewControllers to use
|
// build a new injector for child ViewControllers to use
|
||||||
this.bindings = Injector.resolve([
|
this.providers = Injector.resolve([
|
||||||
bind(NavController).toValue(this)
|
provide(NavController, {useValue: this})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -537,12 +524,12 @@ export class NavController extends Ion {
|
|||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
loadNextToAnchor(type, location, viewCtrl) {
|
loadNextToAnchor(type, location, viewCtrl) {
|
||||||
let bindings = this.bindings.concat(Injector.resolve([
|
let providers = this.providers.concat(Injector.resolve([
|
||||||
bind(ViewController).toValue(viewCtrl),
|
provide(ViewController, {useValue: viewCtrl}),
|
||||||
bind(NavParams).toValue(viewCtrl.params),
|
provide(NavParams, {useValue: viewCtrl.params})
|
||||||
]));
|
]));
|
||||||
|
|
||||||
return this._loader.loadNextToLocation(type, location, bindings);
|
return this._loader.loadNextToLocation(type, location, providers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +11,7 @@ function randomTitle() {
|
|||||||
|
|
||||||
@App({
|
@App({
|
||||||
templateUrl: 'main.html',
|
templateUrl: 'main.html',
|
||||||
bindings: [NgControl],
|
providers: [NgControl],
|
||||||
directives: [FORM_DIRECTIVES]
|
directives: [FORM_DIRECTIVES]
|
||||||
})
|
})
|
||||||
class IonicApp {
|
class IonicApp {
|
||||||
|
@ -11,7 +11,7 @@ function randomTitle() {
|
|||||||
|
|
||||||
@App({
|
@App({
|
||||||
templateUrl: 'main.html',
|
templateUrl: 'main.html',
|
||||||
bindings: [NgControl],
|
providers: [NgControl],
|
||||||
directives: [FORM_DIRECTIVES]
|
directives: [FORM_DIRECTIVES]
|
||||||
})
|
})
|
||||||
class IonicApp {
|
class IonicApp {
|
||||||
|
@ -5,7 +5,7 @@ import {App} from 'ionic/ionic';
|
|||||||
|
|
||||||
@App({
|
@App({
|
||||||
templateUrl: 'main.html',
|
templateUrl: 'main.html',
|
||||||
bindings: [FormBuilder],
|
providers: [FormBuilder],
|
||||||
directives: [FORM_DIRECTIVES]
|
directives: [FORM_DIRECTIVES]
|
||||||
})
|
})
|
||||||
class MyApp {
|
class MyApp {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {bootstrap, bind} from 'angular2/angular2';
|
import {bootstrap, provide} from 'angular2/angular2';
|
||||||
import {routerBindings, HashLocationStrategy, LocationStrategy} from 'angular2/router';
|
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
|
||||||
|
|
||||||
import {IonicApp} from '../components/app/app';
|
import {IonicApp} from '../components/app/app';
|
||||||
import {IonicConfig} from './config';
|
import {IonicConfig} from './config';
|
||||||
@ -18,7 +18,7 @@ import {TapClick} from '../components/tap-click/tap-click';
|
|||||||
import * as dom from '../util/dom';
|
import * as dom from '../util/dom';
|
||||||
|
|
||||||
|
|
||||||
export function ionicBindings(rootCmp, config) {
|
export function ionicProviders(config) {
|
||||||
let app = new IonicApp();
|
let app = new IonicApp();
|
||||||
let platform = new IonicPlatform();
|
let platform = new IonicPlatform();
|
||||||
|
|
||||||
@ -42,11 +42,11 @@ export function ionicBindings(rootCmp, config) {
|
|||||||
platform.prepareReady(config);
|
platform.prepareReady(config);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
bind(IonicApp).toValue(app),
|
provide(IonicApp, {useValue: app}),
|
||||||
bind(IonicConfig).toValue(config),
|
provide(IonicConfig, {useValue: config}),
|
||||||
bind(IonicPlatform).toValue(platform),
|
provide(IonicPlatform, {useValue: platform}),
|
||||||
bind(TapClick).toValue(tapClick),
|
provide(TapClick, {useValue: tapClick}),
|
||||||
bind(Events).toValue(events),
|
provide(Events, {useValue: events}),
|
||||||
IonicForm,
|
IonicForm,
|
||||||
IonicKeyboard,
|
IonicKeyboard,
|
||||||
OverlayController,
|
OverlayController,
|
||||||
@ -55,8 +55,8 @@ export function ionicBindings(rootCmp, config) {
|
|||||||
Popup,
|
Popup,
|
||||||
Translate,
|
Translate,
|
||||||
NavRegistry,
|
NavRegistry,
|
||||||
routerBindings(rootCmp),
|
ROUTER_PROVIDERS,
|
||||||
bind(LocationStrategy).toClass(HashLocationStrategy),
|
provide(LocationStrategy, {useClass: HashLocationStrategy}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {Component, Directive, View, bootstrap} from 'angular2/angular2'
|
import {Component, Directive, View, bootstrap} from 'angular2/angular2'
|
||||||
|
|
||||||
import * as util from 'ionic/util';
|
import * as util from 'ionic/util';
|
||||||
import {ionicBindings} from './bootstrap';
|
import {ionicProviders} from './bootstrap';
|
||||||
import {IONIC_DIRECTIVES} from './directives';
|
import {IONIC_DIRECTIVES} from './directives';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,7 +143,7 @@ export function App(args={}) {
|
|||||||
// redefine with added annotations
|
// redefine with added annotations
|
||||||
Reflect.defineMetadata('annotations', annotations, cls);
|
Reflect.defineMetadata('annotations', annotations, cls);
|
||||||
|
|
||||||
bootstrap(cls, ionicBindings(cls, args.config));
|
bootstrap(cls, ionicProviders(args.config));
|
||||||
|
|
||||||
return cls;
|
return cls;
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,32 @@
|
|||||||
import {IonicConfig, IonicPlatform, ionicBindings} from 'ionic/ionic';
|
import {IonicConfig, IonicPlatform, ionicProviders} from 'ionic/ionic';
|
||||||
|
|
||||||
export function run() {
|
export function run() {
|
||||||
|
|
||||||
it('should create a new IonicConfig instace when no confg passed in ionicBindings', () => {
|
it('should create a new IonicConfig instace when no confg passed in ionicProviders', () => {
|
||||||
let rootCmp = function(){};
|
let providers = ionicProviders();
|
||||||
let bindings = ionicBindings(rootCmp);
|
|
||||||
|
|
||||||
let config = bindings.find(binding => binding.toValue instanceof IonicConfig).toValue;
|
let config = providers.find(provider => provider.useValue instanceof IonicConfig).useValue;
|
||||||
|
|
||||||
expect(config.get('mode')).toEqual('ios');
|
expect(config.get('mode')).toEqual('ios');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should used passed in IonicConfig instance in ionicBindings', () => {
|
it('should used passed in IonicConfig instance in ionicProviders', () => {
|
||||||
let rootCmp = function(){};
|
|
||||||
let userConfig = new IonicConfig({
|
let userConfig = new IonicConfig({
|
||||||
mode: 'configInstance'
|
mode: 'configInstance'
|
||||||
})
|
})
|
||||||
let bindings = ionicBindings(rootCmp, userConfig);
|
let providers = ionicProviders(userConfig);
|
||||||
|
|
||||||
let config = bindings.find(binding => binding.toValue instanceof IonicConfig).toValue;
|
let config = providers.find(provider => provider.useValue instanceof IonicConfig).useValue;
|
||||||
|
|
||||||
expect(config.get('mode')).toEqual('configInstance');
|
expect(config.get('mode')).toEqual('configInstance');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create new IonicConfig instance from config object in ionicBindings', () => {
|
it('should create new IonicConfig instance from config object in ionicProviders', () => {
|
||||||
let rootCmp = function(){};
|
let providers = ionicProviders({
|
||||||
let bindings = ionicBindings(rootCmp, {
|
|
||||||
mode: 'configObj'
|
mode: 'configObj'
|
||||||
});
|
});
|
||||||
|
|
||||||
let config = bindings.find(binding => binding.toValue instanceof IonicConfig).toValue;
|
let config = providers.find(provider => provider.useValue instanceof IonicConfig).useValue;
|
||||||
|
|
||||||
expect(config.get('mode')).toEqual('configObj');
|
expect(config.get('mode')).toEqual('configObj');
|
||||||
});
|
});
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
"link": "npm install && gulp src && npm link"
|
"link": "npm install && gulp src && npm link"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"angular2": "2.0.0-alpha.40",
|
"angular2": "2.0.0-alpha.42",
|
||||||
"@reactivex/rxjs": "0.0.0-prealpha.3",
|
"@reactivex/rxjs": "0.0.0-prealpha.3",
|
||||||
"reflect-metadata": "0.1.1",
|
"reflect-metadata": "0.1.1",
|
||||||
"zone.js": "0.5.8"
|
"zone.js": "0.5.8"
|
||||||
|
Reference in New Issue
Block a user