diff --git a/js/angular/directive/item.js b/js/angular/directive/item.js index 5e25f278d07..1e690010c8a 100644 --- a/js/angular/directive/item.js +++ b/js/angular/directive/item.js @@ -1,7 +1,3 @@ -var ITEM_TPL_CONTENT_ANCHOR = - ''; -var ITEM_TPL_CONTENT = - '
'; /** * @ngdoc directive * @name ionItem @@ -45,11 +41,20 @@ IonicModule /ion-(delete|option|reorder)-button/i.test($element.html()); if (isComplexItem) { - var innerElement = jqLite(isAnchor ? ITEM_TPL_CONTENT_ANCHOR : ITEM_TPL_CONTENT); + var innerElement = jqLite(isAnchor ? '' : ''); + innerElement.addClass('item-content'); + + if (isDefined($attrs.href) || isDefined($attrs.ngHref)) { + innerElement.attr('ng-href', '{{$href()}}') + if (isDefined($attrs.target)) { + innerElement.attr('target', '{{$target()}}') + } + } + innerElement.append($element.contents()); - $element.append(innerElement); - $element.addClass('item item-complex'); + $element.addClass('item item-complex') + .append(innerElement); } else { $element.addClass('item'); } @@ -59,7 +64,7 @@ IonicModule return $attrs.href || $attrs.ngHref; }; $scope.$target = function() { - return $attrs.target || '_self'; + return $attrs.target; }; var content = $element[0].querySelector('.item-content'); diff --git a/test/unit/angular/directive/item.unit.js b/test/unit/angular/directive/item.unit.js index 7179f1f829a..40b88cfa4f0 100644 --- a/test/unit/angular/directive/item.unit.js +++ b/test/unit/angular/directive/item.unit.js @@ -34,9 +34,9 @@ describe('ionItem directive', function() { expect(el.children().attr('href')).toBe('something/44'); }); }); - it('complex item should have target self by default', function() { + it('complex item should not have target by default', function() { var el = setup('href="foo"'); - expect(el.find('a').attr('target')).toBe('_self'); + expect(el.find('a').attr('target')).toBeUndefined(); }); it('complex item should have target if specified', function() { var el = setup('href="foo" target="bar"');