fix for ng:include does not remove partial if src goes to undefined

This commit is contained in:
Igor Minar 2010-08-16 16:47:39 -07:00
parent 59401b80ee
commit 0df7329a6a
2 changed files with 17 additions and 0 deletions

View file

@ -260,6 +260,8 @@ angularWidget('ng:include', function(element){
compiler.compile(element)(element, childScope);
childScope.$init();
});
} else {
element.html('');
}
});
};

View file

@ -436,6 +436,21 @@ describe("widget", function(){
scope.$init();
expect(element.text()).toEqual('misko');
});
it('should remove previously included text if a falsy value is bound to src', function() {
var element = jqLite('<ng:include src="url" scope="childScope"></ng:include>');
var scope = angular.compile(element);
scope.childScope = createScope();
scope.childScope.name = 'igor';
scope.url = 'myUrl';
scope.$xhr.cache.data.myUrl = {value:'{{name}}'};
scope.$init();
scope.url = undefined;
scope.$eval();
expect(element.text()).toEqual('');
});
});
});