addPanel.js 909 B

123456789101112131415161718192021222324252627282930
  1. define([
  2. 'angular',
  3. 'app',
  4. 'underscore'
  5. ],
  6. function (angular, app, _) {
  7. 'use strict';
  8. angular
  9. .module('kibana.directives')
  10. .directive('addPanel', function($compile) {
  11. return {
  12. restrict: 'A',
  13. link: function($scope, elem) {
  14. $scope.$watch('panel.type', function() {
  15. var _type = $scope.panel.type;
  16. $scope.reset_panel(_type);
  17. if(!_.isUndefined($scope.panel.type)) {
  18. $scope.panel.loadingEditor = true;
  19. $scope.require(['panels/'+$scope.panel.type+'/module'], function () {
  20. var template = '<div ng-controller="'+$scope.panel.type+'" ng-include="\'app/partials/paneladd.html\'"></div>';
  21. elem.html($compile(angular.element(template))($scope));
  22. $scope.panel.loadingEditor = false;
  23. });
  24. }
  25. });
  26. }
  27. };
  28. });
  29. });