mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* build(webpack): replace babel-loader with esbuild-loader * build(webpack): add esbuild minifier to production builds * Wip * Removed ngInject and replaced with manual inject params * chore: bump esbuild to 0.15.13 * Fixed angular issues * build(frontend): update esbuild to 0.16.16 * chore(webpack): support browserslist for esbuild * build(esbuild): unify versions of esbuild to 0.16.17 and esbuild-loader to 2.21.0 Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import angular from 'angular';
|
|
import { assign } from 'lodash';
|
|
|
|
import { AngularComponent, AngularLoader as AngularLoaderInterface } from '@grafana/runtime';
|
|
import { GrafanaRootScope } from 'app/angular/GrafanaCtrl';
|
|
import coreModule from 'app/angular/core_module';
|
|
|
|
export class AngularLoader implements AngularLoaderInterface {
|
|
static $inject = ['$compile', '$rootScope'];
|
|
|
|
constructor(private $compile: any, private $rootScope: GrafanaRootScope) {}
|
|
|
|
load(elem: any, scopeProps: any, template: string): AngularComponent {
|
|
const scope = this.$rootScope.$new();
|
|
|
|
assign(scope, scopeProps);
|
|
|
|
const compiledElem = this.$compile(template)(scope);
|
|
const rootNode = angular.element(elem);
|
|
rootNode.append(compiledElem);
|
|
|
|
return {
|
|
destroy: () => {
|
|
scope.$destroy();
|
|
compiledElem.remove();
|
|
},
|
|
digest: () => {
|
|
if (!scope.$$phase) {
|
|
scope.$digest();
|
|
}
|
|
},
|
|
getScope: () => {
|
|
return scope;
|
|
},
|
|
};
|
|
}
|
|
}
|
|
|
|
coreModule.service('angularLoader', AngularLoader);
|