mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
chore(): migrate vue to typescript (#15928)
This commit is contained in:

committed by
Mike Hartington

parent
d800c48734
commit
e251ca71b4
17
vue/src/api-utils.ts
Normal file
17
vue/src/api-utils.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { HTMLStencilElement } from './interfaces';
|
||||
|
||||
// A proxy method that initializes the controller and calls requested method
|
||||
export function proxyMethod(tag: string, method: string, ...opts: any[]): Promise<any> {
|
||||
return initController(tag).then((ctrl: any) => ctrl[method].apply(ctrl, opts));
|
||||
}
|
||||
|
||||
// Initialize an Ionic controller and append it to DOM
|
||||
export function initController(tag: string): Promise<HTMLStencilElement> {
|
||||
let element = document.querySelector(tag) as HTMLElement;
|
||||
|
||||
if (!element) {
|
||||
element = document.body.appendChild(document.createElement(tag));
|
||||
}
|
||||
|
||||
return (element as HTMLStencilElement).componentOnReady();
|
||||
}
|
Reference in New Issue
Block a user