update to alpha42

This commit is contained in:
Adam Bradley
2015-10-14 10:08:26 -05:00
parent b59e30329c
commit a0b8f6f537
9 changed files with 39 additions and 55 deletions

View File

@ -4,7 +4,7 @@ import {Page} from 'ionic/ionic';
@Page({
templateUrl: 'forms/forms.html',
bindings: [FormBuilder]
providers: [FormBuilder]
})
export class FormsPage {

View File

@ -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 {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
* 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
* binding and dependency injection, see [Binding and DI]().
* Tab) and adds the injector to its own providers. For more information on
* providers and dependency injection, see [Providers and DI]().
*
* ```ts
* // class NavController
* //"this" is either Nav or Tab, both extend NavController
* this.bindings = Injector.resolve([
* bind(NavController).toValue(this)
* this.providers = Injector.resolve([
* provide(NavController, {useValue: 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
* navigation controller for most situations (for more advanced situations, see
* [Menu](../../Menu/Menu/) and [Tab](../../Tab/Tab/)).
@ -146,8 +133,8 @@ export class NavController extends Ion {
this._ids = -1;
// build a new injector for child ViewControllers to use
this.bindings = Injector.resolve([
bind(NavController).toValue(this)
this.providers = Injector.resolve([
provide(NavController, {useValue: this})
]);
}
@ -537,12 +524,12 @@ export class NavController extends Ion {
* TODO
*/
loadNextToAnchor(type, location, viewCtrl) {
let bindings = this.bindings.concat(Injector.resolve([
bind(ViewController).toValue(viewCtrl),
bind(NavParams).toValue(viewCtrl.params),
let providers = this.providers.concat(Injector.resolve([
provide(ViewController, {useValue: viewCtrl}),
provide(NavParams, {useValue: viewCtrl.params})
]));
return this._loader.loadNextToLocation(type, location, bindings);
return this._loader.loadNextToLocation(type, location, providers);
}
/**

View File

@ -11,7 +11,7 @@ function randomTitle() {
@App({
templateUrl: 'main.html',
bindings: [NgControl],
providers: [NgControl],
directives: [FORM_DIRECTIVES]
})
class IonicApp {

View File

@ -11,7 +11,7 @@ function randomTitle() {
@App({
templateUrl: 'main.html',
bindings: [NgControl],
providers: [NgControl],
directives: [FORM_DIRECTIVES]
})
class IonicApp {

View File

@ -5,7 +5,7 @@ import {App} from 'ionic/ionic';
@App({
templateUrl: 'main.html',
bindings: [FormBuilder],
providers: [FormBuilder],
directives: [FORM_DIRECTIVES]
})
class MyApp {

View File

@ -1,5 +1,5 @@
import {bootstrap, bind} from 'angular2/angular2';
import {routerBindings, HashLocationStrategy, LocationStrategy} from 'angular2/router';
import {bootstrap, provide} from 'angular2/angular2';
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
import {IonicApp} from '../components/app/app';
import {IonicConfig} from './config';
@ -18,7 +18,7 @@ import {TapClick} from '../components/tap-click/tap-click';
import * as dom from '../util/dom';
export function ionicBindings(rootCmp, config) {
export function ionicProviders(config) {
let app = new IonicApp();
let platform = new IonicPlatform();
@ -42,11 +42,11 @@ export function ionicBindings(rootCmp, config) {
platform.prepareReady(config);
return [
bind(IonicApp).toValue(app),
bind(IonicConfig).toValue(config),
bind(IonicPlatform).toValue(platform),
bind(TapClick).toValue(tapClick),
bind(Events).toValue(events),
provide(IonicApp, {useValue: app}),
provide(IonicConfig, {useValue: config}),
provide(IonicPlatform, {useValue: platform}),
provide(TapClick, {useValue: tapClick}),
provide(Events, {useValue: events}),
IonicForm,
IonicKeyboard,
OverlayController,
@ -55,8 +55,8 @@ export function ionicBindings(rootCmp, config) {
Popup,
Translate,
NavRegistry,
routerBindings(rootCmp),
bind(LocationStrategy).toClass(HashLocationStrategy),
ROUTER_PROVIDERS,
provide(LocationStrategy, {useClass: HashLocationStrategy}),
];
}

View File

@ -1,7 +1,7 @@
import {Component, Directive, View, bootstrap} from 'angular2/angular2'
import * as util from 'ionic/util';
import {ionicBindings} from './bootstrap';
import {ionicProviders} from './bootstrap';
import {IONIC_DIRECTIVES} from './directives';
/**
@ -143,7 +143,7 @@ export function App(args={}) {
// redefine with added annotations
Reflect.defineMetadata('annotations', annotations, cls);
bootstrap(cls, ionicBindings(cls, args.config));
bootstrap(cls, ionicProviders(args.config));
return cls;
}

View File

@ -1,35 +1,32 @@
import {IonicConfig, IonicPlatform, ionicBindings} from 'ionic/ionic';
import {IonicConfig, IonicPlatform, ionicProviders} from 'ionic/ionic';
export function run() {
it('should create a new IonicConfig instace when no confg passed in ionicBindings', () => {
let rootCmp = function(){};
let bindings = ionicBindings(rootCmp);
it('should create a new IonicConfig instace when no confg passed in ionicProviders', () => {
let providers = ionicProviders();
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');
});
it('should used passed in IonicConfig instance in ionicBindings', () => {
let rootCmp = function(){};
it('should used passed in IonicConfig instance in ionicProviders', () => {
let userConfig = new IonicConfig({
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');
});
it('should create new IonicConfig instance from config object in ionicBindings', () => {
let rootCmp = function(){};
let bindings = ionicBindings(rootCmp, {
it('should create new IonicConfig instance from config object in ionicProviders', () => {
let providers = ionicProviders({
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');
});

View File

@ -11,7 +11,7 @@
"link": "npm install && gulp src && npm link"
},
"dependencies": {
"angular2": "2.0.0-alpha.40",
"angular2": "2.0.0-alpha.42",
"@reactivex/rxjs": "0.0.0-prealpha.3",
"reflect-metadata": "0.1.1",
"zone.js": "0.5.8"