该指令(隔离作用域,转换,替换)将一个掩码插入到
有什么想法,为什么这不起作用?
<body>
中。var mask = angular.element('<div id="mask"></div>');
$document.find('body').append(mask);
scope.$on('$destroy', function() {
mask.remove();
});
我正在尝试通过对范围进行简单广播来测试此案例:
var $document, scope, element, rootScope;
beforeEach(inject(function($compile, _$document_, $rootScope, $injector) {
rootScope = $injector.get('$rootScope');
scope = $rootScope;
$document = _$document_;
mask = $document.find('#mask');
element = $compile(angular.element('<overlay id="derp"></overlay>'))(scope);
}));
it('should remove mask when casting the $destory event', function (done) {
scope.$broadcast('$destroy');
scope.$digest();
expect($document.find('#mask').length).toBe(0);
});
有什么想法,为什么这不起作用?