ionic-app-helper¶
Source | ionic-app-helper |
---|
This collection of functions helps you to handle nested ionic angular application starting. Each of the following functions are exposed by the angular-core module and can be imported using the following mechanism:
import {
createIonicAppElement,
referenceApplicationRef,
startAngularApplication,
stopAngularApplication,
} from 'angular-core';
createIonicAppElement referenceApplicationRef startAngularApplication stopAngularApplication
createIonicAppElement¶
createIonicAppElement(container, name);
creates an ionic app container element, appends the dbcp name as id, add evan class names and sets the ‘angular-application-ref’ property to know, whichs runtime reference needs to deleted later.
Parameters¶
container
-Element
: container of the application that should be bootstrappedname
-string
: DBCP.public.name
Returns¶
Element
: returns the new ionic-app element
Example¶
export async function startDApp(container, dbcpName) {
const ionicAppEl = createIonicAppElement(container, dbcpName);
await startAngularApplication(DashboardModule, getRoutes());
container.appendChild(ionicAppEl);
}
referenceApplicationRef¶
referenceApplicationRef(applicationRef, elementRef);
Is used to cache an angular application ref to global context, to be able to clear everything correct. This is used in combination with the BootstrapComponent of the angular-core.
Parameters¶
applicationRef
-ApplicationRef
: Angular application refelementRef
-Element
: element of the application to handle the applicationRefID
startAngularApplication¶
startAngularApplication(AppModule, routes);
Starts an angular module within a container and applies root routes.
Parameters¶
AppModule
-any
: Angular module definitionroutes
-Routes
: Angular 5 route definitions
Returns¶
any
: returns platformBrowser.bootstrapModuleFactory result
Example¶
export async function startDApp(container, dbcpName) {
const ionicAppEl = createIonicAppElement(container, dbcpName);
await startAngularApplication(DashboardModule, getRoutes());
container.appendChild(ionicAppEl);
}
stopAngularApplication¶
stopAngularApplication(container);
Stops an angular application using the element reference that were created by createIonicAppElement.
Parameters¶
container
-Element
: container of the application
Example¶
// for stopping of all ionic angular applications within the dom
const appElements = document.getElementsByTagName('ion-app');
for (let i = 0; i < appElements.length; i++) {
stopAngularApplication(appElements[i].parentElement);
}