[Selection] Sketch in AngularView

...for use in the adapter layer.
This commit is contained in:
Victor Woeltjen
2016-09-21 15:39:56 -07:00
parent 75bf956c3d
commit c46c42e576

View 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;
});