diff --git a/demos/component-docs/forms/forms.ts b/demos/component-docs/forms/forms.ts index 49d5a5361b..f380b609bf 100644 --- a/demos/component-docs/forms/forms.ts +++ b/demos/component-docs/forms/forms.ts @@ -4,7 +4,7 @@ import {Page} from 'ionic/ionic'; @Page({ templateUrl: 'forms/forms.html', - bindings: [FormBuilder] + providers: [FormBuilder] }) export class FormsPage { @@ -20,7 +20,7 @@ export class FormsPage { console.log(event); } - + } @Page({ diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index 8706a8e97e..dfeb776996 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -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); } /** diff --git a/ionic/components/search-bar/test/basic/index.ts b/ionic/components/search-bar/test/basic/index.ts index f45fc52ed5..a97b9719cd 100644 --- a/ionic/components/search-bar/test/basic/index.ts +++ b/ionic/components/search-bar/test/basic/index.ts @@ -11,7 +11,7 @@ function randomTitle() { @App({ templateUrl: 'main.html', - bindings: [NgControl], + providers: [NgControl], directives: [FORM_DIRECTIVES] }) class IonicApp { diff --git a/ionic/components/search-bar/test/model/index.ts b/ionic/components/search-bar/test/model/index.ts index 77b2361ad6..b8b38b879e 100644 --- a/ionic/components/search-bar/test/model/index.ts +++ b/ionic/components/search-bar/test/model/index.ts @@ -11,7 +11,7 @@ function randomTitle() { @App({ templateUrl: 'main.html', - bindings: [NgControl], + providers: [NgControl], directives: [FORM_DIRECTIVES] }) class IonicApp { diff --git a/ionic/components/segment/test/basic/index.ts b/ionic/components/segment/test/basic/index.ts index af8c48ec61..1f2cdfc02d 100644 --- a/ionic/components/segment/test/basic/index.ts +++ b/ionic/components/segment/test/basic/index.ts @@ -5,7 +5,7 @@ import {App} from 'ionic/ionic'; @App({ templateUrl: 'main.html', - bindings: [FormBuilder], + providers: [FormBuilder], directives: [FORM_DIRECTIVES] }) class MyApp { diff --git a/ionic/config/bootstrap.ts b/ionic/config/bootstrap.ts index 14c1389541..c518b87142 100644 --- a/ionic/config/bootstrap.ts +++ b/ionic/config/bootstrap.ts @@ -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}), ]; } diff --git a/ionic/config/decorators.ts b/ionic/config/decorators.ts index d48405ec14..4095bbb0ba 100644 --- a/ionic/config/decorators.ts +++ b/ionic/config/decorators.ts @@ -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; } diff --git a/ionic/config/test/config.spec.ts b/ionic/config/test/config.spec.ts index 0e1853743c..49224f550c 100644 --- a/ionic/config/test/config.spec.ts +++ b/ionic/config/test/config.spec.ts @@ -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'); }); diff --git a/package.json b/package.json index 82522dfa6a..cdcbe948db 100644 --- a/package.json +++ b/package.json @@ -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"