This repository was archived by the owner on Aug 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbootstrap.ts
More file actions
45 lines (32 loc) · 1.24 KB
/
bootstrap.ts
File metadata and controls
45 lines (32 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
import {METEOR_PROVIDERS} from 'angular2-meteor';
import {App, IONIC_DIRECTIVES, ionicProviders, TapClick} from 'ionic/ionic';
import {bootstrap} from 'angular2/platform/browser';
import {Component} from 'angular2/core';
/**
* Simply copy&paste Ionic2 bootstrap decorator to change
* the app selector to 'app' (only way currently) and
* add Meteor providers.
*/
export function MeteorApp(args: any={}) {
return function(cls) {
let annotations = Reflect.getMetadata('annotations', cls) || [];
args.selector = 'app';
// auto add Ionic directives
args.directives = args.directives ? args.directives.concat(IONIC_DIRECTIVES) : IONIC_DIRECTIVES;
// if no template was provided, default so it has a root <ion-nav>
if (!args.templateUrl && !args.template) {
args.template = '<ion-nav></ion-nav>';
}
// create @Component
annotations.push(new Component(args));
// redefine with added annotations
Reflect.defineMetadata('annotations', annotations, cls);
// define array of bootstrap providers
let providers = ionicProviders(args).concat(args.providers || [], METEOR_PROVIDERS);
bootstrap(cls, providers).then(appRef => {
appRef.injector.get(TapClick);
});
return cls;
}
}