[AngularJS 1.4 directives: scope, two way binding and bindToController
任何人使用业力测试指令,我无法获得范围。
beforeEach(inject(function(
$rootScope,
$compile) {
scope = $rootScope.$new();
element = angular.element(
"<div class='myAddress'>" +
"<md-address address="vm.address"></md-address>" +
"</div>"
);
$compile(element)(scope);
scope = element.isolateScope() || element.scope();
}));
任何人都可以帮助我吗?
答案 0 :(得分:0)
我认为你错过了一个范围。$ apply()就在你调用$ compile之后,所以:
beforeEach(inject(function(
$rootScope,
$compile) {
scope = $rootScope.$new();
element = angular.element(
"<div class='myAddress'>" +
"<md-address address="vm.address"></md-address>" +
"</div>"
);
$compile(element)(scope);
scope.$apply();
scope = element.isolateScope();
}));