[Selection] Use AngularView for context menus

This commit is contained in:
Victor Woeltjen 2016-09-26 11:43:38 -07:00
parent 15ef89f455
commit 3b4239fbd9
2 changed files with 15 additions and 11 deletions

View File

@ -1,6 +1,7 @@
define(['angular'], function (angular) {
function AngularView(template) {
function AngularView(template, scopeFn) {
this.template = template;
this.scopeFn = scopeFn;
}
AngularView.prototype.show = function (container) {
@ -12,6 +13,9 @@ define(['angular'], function (angular) {
var $compile = $injector.get('$compile');
var $rootScope = $injector.get('$rootScope');
var $scope = $rootScope.$new();
this.scopeFn($scope);
var elements = $compile(this.template)($scope);
angular.element(container).append(elements);

View File

@ -1,16 +1,16 @@
define(['zepto'], function ($) {
define([
'zepto',
'text!./context-menu.html',
'../../adapter/ui/AngularView'
], function ($, template, AngularView) {
function ContextMenuView(actions) {
this.actions = actions;
AngularView.call(this, template, function ($scope) {
$scope.actions = actions;
});
}
ContextMenuView.prototype.show = function (element) {
var $els = $('<span>Hello context menu!</span>');
$(element).append($els);
};
ContextMenuView.prototype.destroy = function () {
};
ContextMenuView.prototype = Object.create(AngularView.prototype);
return ContextMenuView;
});