UNPKG

19.8 kBJavaScriptView Raw
1/**
2 * Import Angular
3 */
4import { ANALYZE_FOR_ENTRY_COMPONENTS, APP_INITIALIZER, ComponentFactoryResolver, Inject, Injector, NgModule, NgZone, Optional } from '@angular/core';
5import { APP_BASE_HREF, HashLocationStrategy, Location, LocationStrategy, PathLocationStrategy, PlatformLocation } from '@angular/common';
6import { DOCUMENT, HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
7import { FormsModule, ReactiveFormsModule } from '@angular/forms';
8import { CommonModule } from '@angular/common';
9/**
10 * Global Providers
11 */
12import { App } from './components/app/app';
13import { AppRootToken } from './components/app/app-root';
14import { Config, ConfigToken, setupConfig } from './config/config';
15import { DeepLinker, setupDeepLinker } from './navigation/deep-linker';
16import { DomController } from './platform/dom-controller';
17import { Events, setupProvideEvents } from './util/events';
18import { Form } from './util/form';
19import { GestureController } from './gestures/gesture-controller';
20import { IonicGestureConfig } from './gestures/gesture-config';
21import { Haptic } from './tap-click/haptic';
22import { Keyboard } from './platform/keyboard';
23import { LAZY_LOADED_TOKEN, ModuleLoader, provideModuleLoader, setupPreloading } from './util/module-loader';
24import { NgModuleLoader } from './util/ng-module-loader';
25import { Platform, setupPlatform } from './platform/platform';
26import { PlatformConfigToken, providePlatformConfigs } from './platform/platform-registry';
27import { TapClick, setupTapClick } from './tap-click/tap-click';
28import { registerModeConfigs } from './config/mode-registry';
29import { TransitionController } from './transitions/transition-controller';
30import { DeepLinkConfigToken, UrlSerializer, setupUrlSerializer } from './navigation/url-serializer';
31/**
32 * Import Components/Directives/Etc
33 */
34import { ActionSheetCmp } from './components/action-sheet/action-sheet-component';
35import { ActionSheetController } from './components/action-sheet/action-sheet-controller';
36import { AlertCmp } from './components/alert/alert-component';
37import { AlertController } from './components/alert/alert-controller';
38import { ClickBlock } from './components/app/click-block';
39import { IonicApp } from './components/app/app-root';
40import { OverlayPortal } from './components/app/overlay-portal';
41import { Avatar } from './components/avatar/avatar';
42import { Backdrop } from './components/backdrop/backdrop';
43import { Badge } from './components/badge/badge';
44import { Button } from './components/button/button';
45import { Card } from './components/card/card';
46import { CardContent } from './components/card/card-content';
47import { CardHeader } from './components/card/card-header';
48import { CardTitle } from './components/card/card-title';
49import { Checkbox } from './components/checkbox/checkbox';
50import { Chip } from './components/chip/chip';
51import { Content } from './components/content/content';
52import { DateTime } from './components/datetime/datetime';
53import { FabButton } from './components/fab/fab';
54import { FabContainer } from './components/fab/fab-container';
55import { FabList } from './components/fab/fab-list';
56import { Col } from './components/grid/col';
57import { Grid } from './components/grid/grid';
58import { Row } from './components/grid/row';
59import { Icon } from './components/icon/icon';
60import { Img } from './components/img/img';
61import { InfiniteScroll } from './components/infinite-scroll/infinite-scroll';
62import { InfiniteScrollContent } from './components/infinite-scroll/infinite-scroll-content';
63import { TextInput } from './components/input/input';
64import { Item } from './components/item/item';
65import { ItemContent } from './components/item/item-content';
66import { ItemDivider } from './components/item/item-divider';
67import { ItemGroup } from './components/item/item-group';
68import { ItemOptions } from './components/item/item-options';
69import { ItemReorder } from './components/item/item-reorder';
70import { ItemSliding } from './components/item/item-sliding';
71import { Reorder } from './components/item/reorder';
72import { Label } from './components/label/label';
73import { List } from './components/list/list';
74import { ListHeader } from './components/list/list-header';
75import { LoadingCmp } from './components/loading/loading-component';
76import { LoadingController } from './components/loading/loading-controller';
77import { Menu } from './components/menu/menu';
78import { MenuClose } from './components/menu/menu-close';
79import { MenuController } from './components/app/menu-controller';
80import { MenuToggle } from './components/menu/menu-toggle';
81import { ModalCmp } from './components/modal/modal-component';
82import { ModalController } from './components/modal/modal-controller';
83import { Nav } from './components/nav/nav';
84import { NavPop } from './components/nav/nav-pop';
85import { NavPopAnchor } from './components/nav/nav-pop-anchor';
86import { NavPush } from './components/nav/nav-push';
87import { NavPushAnchor } from './components/nav/nav-push-anchor';
88import { Note } from './components/note/note';
89import { Option } from './components/option/option';
90import { PickerCmp } from './components/picker/picker-component';
91import { PickerColumnCmp } from './components/picker/picker-column';
92import { PickerController } from './components/picker/picker-controller';
93import { PopoverCmp } from './components/popover/popover-component';
94import { PopoverController } from './components/popover/popover-controller';
95import { RadioButton } from './components/radio/radio-button';
96import { RadioGroup } from './components/radio/radio-group';
97import { Range } from './components/range/range';
98import { RangeKnob } from './components/range/range-knob';
99import { Refresher } from './components/refresher/refresher';
100import { RefresherContent } from './components/refresher/refresher-content';
101import { Scroll } from './components/scroll/scroll';
102import { Searchbar } from './components/searchbar/searchbar';
103import { Segment } from './components/segment/segment';
104import { Select } from './components/select/select';
105import { SelectPopover } from './components/select/select-popover-component';
106import { SegmentButton } from './components/segment/segment-button';
107import { ShowWhen } from './components/show-hide-when/show-when';
108import { HideWhen } from './components/show-hide-when/hide-when';
109import { Slide } from './components/slides/slide';
110import { Slides } from './components/slides/slides';
111import { Spinner } from './components/spinner/spinner';
112import { SplitPane } from './components/split-pane/split-pane';
113import { Tab } from './components/tabs/tab';
114import { TabButton } from './components/tabs/tab-button';
115import { TabHighlight } from './components/tabs/tab-highlight';
116import { Tabs } from './components/tabs/tabs';
117import { Thumbnail } from './components/thumbnail/thumbnail';
118import { ToastCmp } from './components/toast/toast-component';
119import { ToastController } from './components/toast/toast-controller';
120import { Toggle } from './components/toggle/toggle';
121import { Footer } from './components/toolbar/toolbar-footer';
122import { Header } from './components/toolbar/toolbar-header';
123import { Toolbar } from './components/toolbar/toolbar';
124import { ToolbarItem } from './components/toolbar/toolbar-item';
125import { ToolbarTitle } from './components/toolbar/toolbar-title';
126import { Navbar } from './components/toolbar/navbar';
127import { Typography } from './components/typography/typography';
128import { VirtualFooter } from './components/virtual-scroll/virtual-footer';
129import { VirtualHeader } from './components/virtual-scroll/virtual-header';
130import { VirtualItem } from './components/virtual-scroll/virtual-item';
131import { VirtualScroll } from './components/virtual-scroll/virtual-scroll';
132/**
133 * @name IonicModule
134 * @description
135 * IonicModule is an [NgModule](https://angular.io/docs/ts/latest/guide/ngmodule.html) that bootstraps
136 * an Ionic App. By passing a root component, IonicModule will make sure that all of the components,
137 * directives, and providers from the framework are imported.
138 *
139 * Any configuration for the app can be passed as the second argument to `forRoot`. This can be any
140 * valid property from the [Config](/docs/api/config/Config/).
141 *
142 * @usage
143 * ```ts
144 * import { NgModule } from '@angular/core';
145 *
146 * import { IonicApp, IonicModule } from 'ionic-angular';
147 *
148 * import { MyApp } from './app.component';
149 * import { HomePage } from '../pages/home/home';
150 *
151 * @NgModule({
152 * declarations: [
153 * MyApp,
154 * HomePage
155 * ],
156 * imports: [
157 * BrowserModule,
158 * IonicModule.forRoot(MyApp, {
159 *
160 * })
161 * ],
162 * bootstrap: [IonicApp],
163 * entryComponents: [
164 * MyApp,
165 * HomePage
166 * ],
167 * providers: []
168 * })
169 * export class AppModule {}
170 * ```
171 */
172export class IonicModule {
173 /**
174 * Set the root app component for you IonicModule
175 * @param {any} appRoot The root AppComponent for this app.
176 * @param {any} config Config Options for the app. Accepts any config property.
177 * @param {any} deepLinkConfig Any configuration needed for the Ionic Deeplinker.
178 */
179 static forRoot(appRoot, config = null, deepLinkConfig = null) {
180 return {
181 ngModule: IonicModule,
182 providers: [
183 // useValue: bootstrap values
184 { provide: AppRootToken, useValue: appRoot },
185 { provide: ConfigToken, useValue: config },
186 { provide: DeepLinkConfigToken, useValue: deepLinkConfig },
187 { provide: APP_BASE_HREF, useValue: '/' },
188 // useFactory: user values
189 { provide: PlatformConfigToken, useFactory: providePlatformConfigs },
190 // useFactory: ionic core providers
191 { provide: Platform, useFactory: setupPlatform, deps: [DOCUMENT, PlatformConfigToken, NgZone] },
192 { provide: Config, useFactory: setupConfig, deps: [ConfigToken, Platform] },
193 // useFactory: ionic app initializers
194 { provide: APP_INITIALIZER, useFactory: registerModeConfigs, deps: [Config], multi: true },
195 { provide: APP_INITIALIZER, useFactory: setupProvideEvents, deps: [Platform, DomController], multi: true },
196 { provide: APP_INITIALIZER, useFactory: setupTapClick, deps: [Config, Platform, DomController, App, GestureController], multi: true },
197 { provide: APP_INITIALIZER, useFactory: setupPreloading, deps: [Config, DeepLinkConfigToken, ModuleLoader, NgZone], multi: true },
198 // useClass
199 { provide: HAMMER_GESTURE_CONFIG, useClass: IonicGestureConfig },
200 // useValue
201 { provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: appRoot, multi: true },
202 // ionic providers
203 ActionSheetController,
204 AlertController,
205 App,
206 DomController,
207 Events,
208 Form,
209 GestureController,
210 Haptic,
211 Keyboard,
212 LoadingController,
213 Location,
214 MenuController,
215 ModalController,
216 NgModuleLoader,
217 PickerController,
218 PopoverController,
219 TapClick,
220 ToastController,
221 TransitionController,
222 { provide: ModuleLoader, useFactory: provideModuleLoader, deps: [NgModuleLoader, Injector] },
223 { provide: LocationStrategy, useFactory: provideLocationStrategy, deps: [PlatformLocation, [new Inject(APP_BASE_HREF), new Optional()], Config] },
224 { provide: UrlSerializer, useFactory: setupUrlSerializer, deps: [App, DeepLinkConfigToken] },
225 { provide: DeepLinker, useFactory: setupDeepLinker, deps: [App, UrlSerializer, Location, ModuleLoader, ComponentFactoryResolver] },
226 ]
227 };
228 }
229}
230IonicModule.decorators = [
231 { type: NgModule, args: [{
232 declarations: [
233 ActionSheetCmp,
234 AlertCmp,
235 ClickBlock,
236 IonicApp,
237 OverlayPortal,
238 Avatar,
239 Backdrop,
240 Badge,
241 Button,
242 Card,
243 CardContent,
244 CardHeader,
245 CardTitle,
246 Checkbox,
247 Chip,
248 Col,
249 Content,
250 DateTime,
251 FabButton,
252 FabContainer,
253 FabList,
254 Grid,
255 Img,
256 Icon,
257 InfiniteScroll,
258 InfiniteScrollContent,
259 Item,
260 ItemContent,
261 ItemDivider,
262 ItemGroup,
263 ItemOptions,
264 ItemReorder,
265 ItemSliding,
266 Label,
267 List,
268 ListHeader,
269 Reorder,
270 LoadingCmp,
271 Menu,
272 MenuClose,
273 MenuToggle,
274 ModalCmp,
275 Nav,
276 NavPop,
277 NavPopAnchor,
278 NavPush,
279 NavPushAnchor,
280 Note,
281 Option,
282 PickerCmp,
283 PickerColumnCmp,
284 PopoverCmp,
285 RadioButton,
286 RadioGroup,
287 Range,
288 RangeKnob,
289 Refresher,
290 RefresherContent,
291 Row,
292 Scroll,
293 Searchbar,
294 Segment,
295 SegmentButton,
296 Select,
297 SelectPopover,
298 ShowWhen,
299 HideWhen,
300 Slide,
301 Slides,
302 Spinner,
303 SplitPane,
304 Tab,
305 TabButton,
306 TabHighlight,
307 Tabs,
308 TextInput,
309 Thumbnail,
310 ToastCmp,
311 Toggle,
312 Footer,
313 Header,
314 Toolbar,
315 ToolbarItem,
316 ToolbarTitle,
317 Navbar,
318 Typography,
319 VirtualFooter,
320 VirtualHeader,
321 VirtualItem,
322 VirtualScroll
323 ],
324 imports: [
325 CommonModule,
326 FormsModule,
327 ReactiveFormsModule,
328 ],
329 exports: [
330 CommonModule,
331 FormsModule,
332 ReactiveFormsModule,
333 ActionSheetCmp,
334 AlertCmp,
335 ClickBlock,
336 IonicApp,
337 OverlayPortal,
338 Avatar,
339 Backdrop,
340 Badge,
341 Button,
342 Card,
343 CardContent,
344 CardHeader,
345 CardTitle,
346 Checkbox,
347 Chip,
348 Col,
349 Content,
350 DateTime,
351 FabButton,
352 FabContainer,
353 FabList,
354 Grid,
355 Img,
356 Icon,
357 InfiniteScroll,
358 InfiniteScrollContent,
359 Item,
360 ItemContent,
361 ItemDivider,
362 ItemGroup,
363 ItemOptions,
364 ItemReorder,
365 ItemSliding,
366 Label,
367 List,
368 ListHeader,
369 Reorder,
370 LoadingCmp,
371 Menu,
372 MenuClose,
373 MenuToggle,
374 ModalCmp,
375 Nav,
376 NavPop,
377 NavPopAnchor,
378 NavPush,
379 NavPushAnchor,
380 Note,
381 Option,
382 PickerCmp,
383 PickerColumnCmp,
384 PopoverCmp,
385 RadioButton,
386 RadioGroup,
387 Range,
388 RangeKnob,
389 Refresher,
390 RefresherContent,
391 Row,
392 Scroll,
393 Searchbar,
394 Segment,
395 SegmentButton,
396 Select,
397 SelectPopover,
398 ShowWhen,
399 HideWhen,
400 Slide,
401 Slides,
402 Spinner,
403 SplitPane,
404 Tab,
405 TabButton,
406 TabHighlight,
407 Tabs,
408 TextInput,
409 Thumbnail,
410 ToastCmp,
411 Toggle,
412 Footer,
413 Header,
414 Toolbar,
415 ToolbarItem,
416 ToolbarTitle,
417 Navbar,
418 Typography,
419 VirtualFooter,
420 VirtualHeader,
421 VirtualItem,
422 VirtualScroll
423 ],
424 entryComponents: [
425 ActionSheetCmp,
426 AlertCmp,
427 IonicApp,
428 LoadingCmp,
429 ModalCmp,
430 PickerCmp,
431 PopoverCmp,
432 SelectPopover,
433 ToastCmp
434 ]
435 },] },
436];
437/** @nocollapse */
438IonicModule.ctorParameters = () => [];
439/**
440 * @name IonicPageModule
441 * @description
442 * IonicPageModule is an [NgModule](https://angular.io/docs/ts/latest/guide/ngmodule.html) that
443 * bootstraps a child [IonicPage](../navigation/IonicPage/) in order to set up routing.
444 *
445 * @usage
446 * ```ts
447 * import { NgModule } from '@angular/core';
448 *
449 * import { IonicPageModule } from 'ionic-angular';
450 *
451 * import { HomePage } from './home';
452 *
453 * @NgModule({
454 * declarations: [
455 * HomePage
456 * ],
457 * imports: [
458 * IonicPageModule.forChild(HomePage)
459 * ],
460 * entryComponents: [
461 * HomePage
462 * ]
463 * })
464 * export class HomePageModule { }
465 * ```
466 */
467export class IonicPageModule {
468 static forChild(page) {
469 return {
470 ngModule: IonicPageModule,
471 providers: [
472 { provide: LAZY_LOADED_TOKEN, useValue: page },
473 { provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: page, multi: true },
474 ]
475 };
476 }
477}
478IonicPageModule.decorators = [
479 { type: NgModule, args: [{
480 imports: [IonicModule],
481 exports: [IonicModule]
482 },] },
483];
484/** @nocollapse */
485IonicPageModule.ctorParameters = () => [];
486/**
487 * @hidden
488 */
489export function provideLocationStrategy(platformLocationStrategy, baseHref, config) {
490 return config.get('locationStrategy') === 'path' ?
491 new PathLocationStrategy(platformLocationStrategy, baseHref) :
492 new HashLocationStrategy(platformLocationStrategy, baseHref);
493}
494//# sourceMappingURL=module.js.map
\No newline at end of file