ionic-framework
Version:
38 lines • 1.68 kB
JavaScript
var core_1 = require('angular2/core');
var browser_1 = require('angular2/platform/browser');
var tap_click_1 = require('../../components/tap-click/tap-click');
var bootstrap_1 = require('../bootstrap');
var directives_1 = require('../directives');
/**
* @ngdoc service
* @name App
* @module ionic
* @param {object} [config] - the app's [../Config](Config) object
* @param {string} [template] - the template to use for the app root
* @param {string} [templateUrl] - a relative URL pointing to the template to use for the app root
* @description
* App is an Ionic decorator that bootstraps an application. It can be passed a number of arguments, that act as global config variables for the app.
*/
function App(args) {
if (args === void 0) { args = {}; }
return function (cls) {
// get current annotations
var annotations = Reflect.getMetadata('annotations', cls) || [];
args.selector = 'ion-app';
// auto add Ionic directives
args.directives = args.directives ? args.directives.concat(directives_1.IONIC_DIRECTIVES) : directives_1.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 core_1.Component(args));
// redefine with added annotations
Reflect.defineMetadata('annotations', annotations, cls);
browser_1.bootstrap(cls, bootstrap_1.ionicProviders(args)).then(function (appRef) {
appRef.injector.get(tap_click_1.TapClick);
});
return cls;
};
}
exports.App = App;