【发布时间】:2014-10-28 18:31:01
【问题描述】:
我希望从我的 help-button 指令中的孤立作用域中得到一些东西。
it('should contain proper scope, depending on attributes', function() {
var el = compile('<help-button context-id="1"></help-button>')(scope);
scope.$digest();
console.log("el: " + el);
console.log('Isolated scope: ' + el.isolateScope());
..
});
-- 在每次测试之前
beforeEach(inject(function($compile, $rootScope, $injector) {
compile = $compile;
scope = $rootScope.$new(); ...
打印出来:
'el: [Object Object]'
'Isolated scope: undefined'
问题是:为什么我会返回 undefined?即使隔离范围内没有任何内容,它仍然应该是空的 {} 对象。但无论如何 - 测试是错误的 - 它没有显示(实际)包含数据的隔离范围。
【问题讨论】:
标签: javascript angularjs scope jasmine