mirror of
https://github.com/nasa/openmct.git
synced 2025-06-23 09:25:29 +00:00
[Selection] Sketch in AngularView
...for use in the adapter layer.
This commit is contained in:
28
src/adapter/ui/AngularView.js
Normal file
28
src/adapter/ui/AngularView.js
Normal file
@ -0,0 +1,28 @@
|
||||
define(['angular'], function (angular) {
|
||||
function AngularView(template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
AngularView.prototype.show = function (container) {
|
||||
if (this.activeScope) {
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
var $injector = angular.injector(['ng']);
|
||||
var $compile = $injector.get('$compile');
|
||||
var $rootScope = $injector.get('$rootScope');
|
||||
var $scope = $rootScope.$new();
|
||||
var elements = $compile(this.template)($scope);
|
||||
|
||||
angular.element(container).append(elements);
|
||||
};
|
||||
|
||||
AngularView.prototype.destroy = function () {
|
||||
if (this.activeScope) {
|
||||
this.activeScope.$destroy();
|
||||
this.activeScope = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
return AngularView;
|
||||
});
|
Reference in New Issue
Block a user