mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
chore(module): move all providers to IonicModule
This commit is contained in:
113
src/module.ts
113
src/module.ts
@ -1,13 +1,50 @@
|
|||||||
import { ModuleWithProviders, NgModule } from '@angular/core';
|
import { ANALYZE_FOR_ENTRY_COMPONENTS, ModuleWithProviders, NgModule } from '@angular/core';
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule, HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { HttpModule } from '@angular/http';
|
import { HttpModule } from '@angular/http';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import Providers
|
||||||
|
*/
|
||||||
|
import { ActionSheetController } from './components/action-sheet/action-sheet';
|
||||||
|
import { AlertController } from './components/alert/alert';
|
||||||
|
import { App } from './components/app/app';
|
||||||
|
import { provideConfig } from './config/config';
|
||||||
|
import { provideEvents } from './util/events';
|
||||||
|
import { FeatureDetect } from './util/feature-detect';
|
||||||
|
import { Form } from './util/form';
|
||||||
|
import { GestureController } from './gestures/gesture-controller';
|
||||||
|
import { IonicGestureConfig } from './gestures/gesture-config';
|
||||||
|
import { Keyboard } from './util/keyboard';
|
||||||
|
import { LoadingController } from './components/loading/loading';
|
||||||
|
import { MenuController } from './components/menu/menu-controller';
|
||||||
|
import { ModalController } from './components/modal/modal';
|
||||||
|
import { PickerController } from './components/picker/picker';
|
||||||
|
import { providePlatform, UserAgent, UserNavigatorPlatform, UserDir, UserLang } from './platform/platform';
|
||||||
|
import { PopoverController } from './components/popover/popover';
|
||||||
|
import { provideDeepLinker } from './navigation/deep-linker';
|
||||||
|
import { provideQueryParams, UserUrl } from './platform/query-params';
|
||||||
|
import { TapClick, provideTapClick } from './components/tap-click/tap-click';
|
||||||
|
import { ToastController } from './components/toast/toast';
|
||||||
|
import { Translate } from './translation/translate';
|
||||||
|
import { TransitionController } from './transitions/transition-controller';
|
||||||
|
import { UserRoot } from './components/app/app-root';
|
||||||
|
|
||||||
|
)
|
||||||
|
/**
|
||||||
|
* Export Providers
|
||||||
|
*/
|
||||||
|
export { DeepLinker, provideDeepLinker } from './navigation/deep-linker';
|
||||||
|
export { NavController } from './navigation/nav-controller';
|
||||||
|
export { NavParams } from './navigation/nav-params';
|
||||||
|
export { NavLink, NavOptions, DeepLink, DeepLinkConfig } from './navigation/nav-util';
|
||||||
|
export { ViewController } from './navigation/view-controller';
|
||||||
|
|
||||||
import { ActionSheetCmp } from './components/action-sheet/action-sheet-component';
|
import { ActionSheetCmp } from './components/action-sheet/action-sheet-component';
|
||||||
import { AlertCmp } from './components/alert/alert-component';
|
import { AlertCmp } from './components/alert/alert-component';
|
||||||
import { IONIC_DIRECTIVES } from './directives';
|
import { IONIC_DIRECTIVES } from './directives';
|
||||||
import { IonicApp } from './components/app/app-root';
|
import { IonicApp } from './components/app/app-root';
|
||||||
import { ionicProviders } from './providers';
|
|
||||||
import { LoadingCmp } from './components/loading/loading-component';
|
import { LoadingCmp } from './components/loading/loading-component';
|
||||||
import { ModalCmp } from './components/modal/modal-component';
|
import { ModalCmp } from './components/modal/modal-component';
|
||||||
import { PickerCmp } from './components/picker/picker-component';
|
import { PickerCmp } from './components/picker/picker-component';
|
||||||
@ -44,8 +81,76 @@ export class IonicModule {
|
|||||||
static forRoot(userAppRoot: any, userConfig?: any, userDeepLinkConfig?: any): ModuleWithProviders {
|
static forRoot(userAppRoot: any, userConfig?: any, userDeepLinkConfig?: any): ModuleWithProviders {
|
||||||
return {
|
return {
|
||||||
ngModule: IonicModule,
|
ngModule: IonicModule,
|
||||||
providers: ionicProviders(userAppRoot, userConfig, userDeepLinkConfig)
|
providers: [
|
||||||
|
{ provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: userAppRoot, multi: true },
|
||||||
|
{ provide: HAMMER_GESTURE_CONFIG, useClass: IonicGestureConfig },
|
||||||
|
{ provide: UserAgent, useFactory: getWindowUserAgent },
|
||||||
|
{ provide: UserDir, useFactory: getDocumentDir },
|
||||||
|
{ provide: UserLang, useFactory: getDocumentLang },
|
||||||
|
{ provide: UserNavigatorPlatform, useFactory: getWindowPlatform },
|
||||||
|
{ provide: UserRoot, useValue: userAppRoot },
|
||||||
|
{ provide: UserUrl, useFactory: getWindowLocation },
|
||||||
|
|
||||||
|
provideConfig(userConfig),
|
||||||
|
provideDeepLinker(userDeepLinkConfig),
|
||||||
|
provideEvents(),
|
||||||
|
providePlatform(),
|
||||||
|
provideQueryParams(),
|
||||||
|
provideTapClick(),
|
||||||
|
|
||||||
|
ActionSheetController,
|
||||||
|
AlertController,
|
||||||
|
App,
|
||||||
|
Form,
|
||||||
|
FeatureDetect,
|
||||||
|
GestureController,
|
||||||
|
Keyboard,
|
||||||
|
LoadingController,
|
||||||
|
MenuController,
|
||||||
|
ModalController,
|
||||||
|
PickerController,
|
||||||
|
PopoverController,
|
||||||
|
TapClick,
|
||||||
|
ToastController,
|
||||||
|
Translate,
|
||||||
|
TransitionController
|
||||||
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export function getWindowUserAgent() {
|
||||||
|
return window && window.navigator.userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export function getWindowPlatform() {
|
||||||
|
return window && window.navigator.platform;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export function getWindowLocation() {
|
||||||
|
return window && window.location.href;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export function getDocumentDir() {
|
||||||
|
return document && document.documentElement.dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export function getDocumentLang() {
|
||||||
|
return document && document.documentElement.lang;
|
||||||
|
}
|
||||||
|
118
src/providers.ts
118
src/providers.ts
@ -1,118 +0,0 @@
|
|||||||
import { ANALYZE_FOR_ENTRY_COMPONENTS } from '@angular/core';
|
|
||||||
import { HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Import Providers
|
|
||||||
*/
|
|
||||||
import { ActionSheetController } from './components/action-sheet/action-sheet';
|
|
||||||
import { AlertController } from './components/alert/alert';
|
|
||||||
import { App } from './components/app/app';
|
|
||||||
import { provideConfig } from './config/config';
|
|
||||||
import { provideEvents } from './util/events';
|
|
||||||
import { FeatureDetect } from './util/feature-detect';
|
|
||||||
import { Form } from './util/form';
|
|
||||||
import { GestureController } from './gestures/gesture-controller';
|
|
||||||
import { IonicGestureConfig } from './gestures/gesture-config';
|
|
||||||
import { Keyboard } from './util/keyboard';
|
|
||||||
import { LoadingController } from './components/loading/loading';
|
|
||||||
import { MenuController } from './components/menu/menu-controller';
|
|
||||||
import { ModalController } from './components/modal/modal';
|
|
||||||
import { PickerController } from './components/picker/picker';
|
|
||||||
import { providePlatform, UserAgent, UserNavigatorPlatform, UserDir, UserLang } from './platform/platform';
|
|
||||||
import { PopoverController } from './components/popover/popover';
|
|
||||||
import { provideDeepLinker } from './navigation/deep-linker';
|
|
||||||
import { provideQueryParams, UserUrl } from './platform/query-params';
|
|
||||||
import { TapClick, provideTapClick } from './components/tap-click/tap-click';
|
|
||||||
import { ToastController } from './components/toast/toast';
|
|
||||||
import { Translate } from './translation/translate';
|
|
||||||
import { TransitionController } from './transitions/transition-controller';
|
|
||||||
import { UserRoot } from './components/app/app-root';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Export Providers
|
|
||||||
*/
|
|
||||||
export { DeepLinker, provideDeepLinker } from './navigation/deep-linker';
|
|
||||||
export { NavController } from './navigation/nav-controller';
|
|
||||||
export { NavParams } from './navigation/nav-params';
|
|
||||||
export { NavLink, NavOptions, DeepLink, DeepLinkConfig } from './navigation/nav-util';
|
|
||||||
export { ViewController } from './navigation/view-controller';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* ionicProviders used by IonicModule
|
|
||||||
*/
|
|
||||||
export function ionicProviders(userRoot: any, userConfig?: any, userDeepLinkConfig?: any): any[] {
|
|
||||||
return [
|
|
||||||
{ provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: userRoot, multi: true },
|
|
||||||
{ provide: HAMMER_GESTURE_CONFIG, useClass: IonicGestureConfig },
|
|
||||||
{ provide: UserAgent, useFactory: getWindowUserAgent },
|
|
||||||
{ provide: UserDir, useFactory: getDocumentDir },
|
|
||||||
{ provide: UserLang, useFactory: getDocumentLang },
|
|
||||||
{ provide: UserNavigatorPlatform, useFactory: getWindowPlatform },
|
|
||||||
{ provide: UserRoot, useValue: userRoot },
|
|
||||||
{ provide: UserUrl, useFactory: getWindowLocation },
|
|
||||||
|
|
||||||
provideConfig(userConfig),
|
|
||||||
provideDeepLinker(userDeepLinkConfig),
|
|
||||||
provideEvents(),
|
|
||||||
providePlatform(),
|
|
||||||
provideQueryParams(),
|
|
||||||
provideTapClick(),
|
|
||||||
|
|
||||||
ActionSheetController,
|
|
||||||
AlertController,
|
|
||||||
App,
|
|
||||||
Form,
|
|
||||||
FeatureDetect,
|
|
||||||
GestureController,
|
|
||||||
Keyboard,
|
|
||||||
LoadingController,
|
|
||||||
MenuController,
|
|
||||||
ModalController,
|
|
||||||
PickerController,
|
|
||||||
PopoverController,
|
|
||||||
TapClick,
|
|
||||||
ToastController,
|
|
||||||
Translate,
|
|
||||||
TransitionController
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
export function getWindowUserAgent() {
|
|
||||||
return window && window.navigator.userAgent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
export function getWindowPlatform() {
|
|
||||||
return window && window.navigator.platform;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
export function getWindowLocation() {
|
|
||||||
return window && window.location.href;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
export function getDocumentDir() {
|
|
||||||
return document && document.documentElement.dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
export function getDocumentLang() {
|
|
||||||
return document && document.documentElement.lang;
|
|
||||||
}
|
|
Reference in New Issue
Block a user