var ITEM_TPL_CONTENT_ANCHOR = ''; var ITEM_TPL_CONTENT = '
'; /** * @ngdoc directive * @name ionItem * @parent ionic.directive:ionList * @module ionic * @restrict E * Creates a list-item that can easily be swiped, * deleted, reordered, edited, and more. * * See {@link ionic.directive:ionList} for a complete example & explanation. * * Can be assigned any item class name. See the * [list CSS documentation](/docs/components/#list). * * @usage * * ```html * * Hello! * * ``` */ IonicModule .directive('ionItem', [ '$animate', '$compile', function($animate, $compile) { return { restrict: 'E', controller: ['$scope', '$element', function($scope, $element) { this.$scope = $scope; this.$element = $element; }], scope: true, compile: function($element, $attrs) { var isAnchor = angular.isDefined($attrs.href) || angular.isDefined($attrs.ngHref) || angular.isDefined($attrs.uiSref); var isComplexItem = isAnchor || //Lame way of testing, but we have to know at compile what to do with the element /ion-(delete|option|reorder)-button/i.test($element.html()); if (isComplexItem) { var innerElement = jqLite(isAnchor ? ITEM_TPL_CONTENT_ANCHOR : ITEM_TPL_CONTENT); innerElement.append($element.contents()); $element.append(innerElement); $element.addClass('item item-complex'); } else { $element.addClass('item'); } return function link($scope, $element, $attrs) { $scope.$href = function() { return $attrs.href || $attrs.ngHref; }; $scope.$target = function() { return $attrs.target || '_self'; }; }; } }; }]);