Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html ng-app="ionicApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>Ionic List Directive</title>
   
    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
  </head>

  <body ng-controller="MyCtrl">
    
    <ion-header-bar class="bar-positive">
      <h1 class="title">Deleting items on an input list</h1>
      </div>
    </ion-header-bar>

    <ion-content>

      <!-- The list directive is great, but be sure to also checkout the collection repeat directive when scrolling through large lists -->
      
      <ion-list class="input-list">
            <ion-item class="item-remove-animate item-icon-right" ng-repeat="item in items">
                <i open-options class="ion-ios-minus assertive static-delete"></i>
                <label close-options class="item item-input">
                    <input type="text" value="Item {{ item.id }}">
                </label>
                <ion-option-button class="button-assertive" ng-click="meals.splice($index, 1)">
                    Delete
                </ion-option-button>
            </ion-item>
            <ion-item class="add-item">
                <i open-options class="ion-ios-plus balanced static-delete"></i>
                <label class="item item-input">
                    <input type="text" value="Add Item" readonly="readonly">
                </label>
                <ion-option-button>
                </ion-option-button>
            </ion-item>
        </ion-list>

    </ion-content>
      
  </body>
</html>
              
            
!

CSS

              
                .input-list {
	.item-icon-right .item-content {
		padding: 0;
	}
	.item {
		border-right: 0;
	}
	label {
		padding-left: 48px;
	}
	.static-delete {
		position: absolute;
		padding: 10px;
		top: 0;
		left: 2px;
		z-index: 3;
		font-size: 24px;
	}
	input[readonly] {
		background: #fff !important; // don't need important on local build
	}
	.add-item {
		.item-content {
			padding: 0;
		}
	}
}
              
            
!

JS

              
                angular.module('ionicApp', ['ionic'])

.directive('clickForOptionsWrapper', [function() {
	return {
		restrict: 'A',
		controller: function($scope) {
			this.closeOptions = function() {
				$scope.$broadcast('closeOptions');
			}
		}
	};
}])

.directive('openOptions', ['$ionicGesture', function($ionicGesture) {
  return {
    restrict: 'A',
    link: function (scope, element, attrs) {
      $ionicGesture.on('tap', function(e){

        // Grab the content
        var content = element.parent()[0];

        // Grab the buttons and their width
        var buttons = element.parent().parent()[0].querySelector('.item-options');

				// Make the 
        var input = element.parent()[0].querySelector('input');
        angular.element(input).attr('readonly', 'readonly');


        //document.getElementById('foo').readOnly = true;

        if (!buttons) {
          console.log('There are no option buttons');
          return;
        }
        var buttonsWidth = buttons.offsetWidth;

        ionic.requestAnimationFrame(function() {
          //content.style[ionic.CSS.TRANSITION] = 'all ease-out .25s';


            buttons.classList.remove('invisible');
            content.style[ionic.CSS.TRANSFORM] = 'translate3d(-' + buttonsWidth + 'px, 0, 0)';
        });   

      }, element);
    }
  }
}])

.directive('closeOptions', ['$ionicGesture', function($ionicGesture) {
  return {
    restrict: 'A',
    link: function (scope, element, attrs) {
      $ionicGesture.on('touch', function(e){

        // Grab the content
        var content = element.parent()[0];

        // Grab the buttons and their width
        var buttons = element.parent().parent()[0].querySelector('.item-options');

        if (!buttons) {
          console.log('There are no option buttons');
          return;
        }
        var buttonsWidth = buttons.offsetWidth;



        ionic.requestAnimationFrame(function() {
         //content.style[ionic.CSS.TRANSITION] = 'all ease-out .25s';

            console.log('close');
            content.style[ionic.CSS.TRANSFORM] = '';
            setTimeout(function() {
              buttons.classList.add('invisible');

						// change the input back to normal
            var input = element.parent()[0].querySelector('input');
            angular.element(input).attr('readonly', '');

            }, 250);        
        });   
        

      }, element);
    }
  }
}])
	
	
.controller('MyCtrl', function($scope) {
  
  $scope.data = {
    showDelete: false
  };
  
  $scope.edit = function(item) {
    alert('Edit Item: ' + item.id);
  };
  $scope.share = function(item) {
    alert('Share Item: ' + item.id);
  };
  
  $scope.moveItem = function(item, fromIndex, toIndex) {
    $scope.items.splice(fromIndex, 1);
    $scope.items.splice(toIndex, 0, item);
  };
  
  $scope.onItemDelete = function(item) {
    $scope.items.splice($scope.items.indexOf(item), 1);
  };
  
  $scope.items = [
    { id: 0 },
    { id: 1 },
    { id: 2 },
    { id: 3 },
    { id: 4 },
    { id: 5 },
  ];
  
});
              
            
!
999px

Console