Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2119,7 +2119,14 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
forEach(dst, function(value, key) {
if (key.charAt(0) != '$') {
if (src[key] && src[key] !== value) {
value += (key === 'style' ? ';' : ' ') + src[key];
var concatString = ' ';
if (key === 'style') {
concatString = ';';
}
if (key === 'ngIf') { //if ngIf is merged both conditions need to be taken into account
concatString = ' && ';
}
value += concatString + src[key];
}
dst.$set(key, value, true, srcAttr[key]);
}
Expand Down
17 changes: 17 additions & 0 deletions test/ng/directive/ngIfSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,23 @@ describe('ngIf and transcludes', function() {
});
});

it('should allow using ngIf on the target element and on the root element of the directive template when used in a replace mode', function() {
module(function($compileProvider) {
var directive = $compileProvider.directive;
directive('example', valueFn({
template: '<div ng-if="innerCondition">guacamole</div>',
replace: true
}));
});
inject(function($compile, $rootScope) {
$rootScope.innerCondition = true;
$rootScope.outerCondition = true;
var element = $compile('<div><example ng-if="outerCondition"></example></div>')($rootScope);
$rootScope.$apply();
expect(element.text()).toBe('guacamole');
dealoc(element);
});
});

it('should use the correct transcluded scope', function() {
module(function($compileProvider) {
Expand Down