cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <html >
<head>
</head>

<body>
  
  
  <div ng-app="recipeBoxApp" ng-controller="recipeBoxCtrl">

    <h4 class="pull-right"><a href="https://youtu.be/8JqS72z9h0w" target="_blank">Watch tutorial</a></h4>
    
 <div class="container">
  <!-- Row is devided in the list of recipes and add a new one -->
  <div class="row">
   <!-- Left - list with edit/delete-->
   <div class="col-xs-8">
    <ul class="collapsible" data-collapsible="accordion">
     <li ng-repeat="recipe in recipeList | filter track by $index">
      <div class="collapsible-header">{{recipe.title}}</div>
      <div class="collapsible-body">
       <div>{{recipe.ingredients}}</div>
       <div class="recipeBtn">
        <button ng-click="editRecipe($index)">Edit</button>
        <button ng-click="deleteRecipe($index)">Delete</button>
       </div>
      </div>
     </li>
    </ul>
   </div>

   <!-- Right - add recipe -->
   <div class="col-xs-4">
    <div class="card">
     <div class="card-content">
      New recipe
      <form ng-submit="addRecipe()">
       <div class="input-field">
        <input type="text" ng-model="newRecipe" placeholder="Name">
       </div>
       <div class="input-field">
        <input type="text" ng-model="newIngredients" placeholder="Ingredients (Seperate by commas)">
       </div>      
       <button type="submit">Add</button>
      </form>
     </div>
    </div>
   </div> <!-- column -->
  </div> <!-- row -->
   
    <!-- Footer-->
		<div class="row">
			<div class="col-xs-12">
				<div class="tableFooter">
				  <!-- for footer -->
      <div class="col-xs-6">
      <h5><a href="http://www.eleftheriabatsou.com" target="_blank">Eleftheria</a> | <a href="https://codepen.io/EleftheriaBatsou" target="_blank">Projects</a> | <a href="https://www.youtube.com/channel/UCC-WwYv3DEW7Nkm_IP6VeQQ" target="_blank"> Coding videos </a></h5>
      </div>
      <!-- social media -->
      <div class="col-xs-6 text-primary">
        <a href="https://twitter.com/BatsouElef" target="_blank">
     <img class="footerSvg"src="https://image.flaticon.com/icons/svg/60/60580.svg" 
      style="text-align:center" alt="twitter"> 
    </a>
         <a href="https://github.com/EleftheriaBatsou" target="_blank">
     <img class="footerSvg" src="https://image.flaticon.com/icons/svg/25/25657.svg" 
      style="text-align:center" alt="github"> 
    </a>
        <a href="https://www.youtube.com/channel/UCC-WwYv3DEW7Nkm_IP6VeQQ" target="_blank">
     <img class="footerSvg" src="https://image.flaticon.com/icons/svg/25/25312.svg" 
       style="text-align:center" alt="youtube"> 
    </a>
      </div>
    <!-- end footer -->
				</div>
			</div>
		</div>
    <!-- end of Footer -->
   
 </div> <!--container -->
</div> <!-- app -->

  
   
  
  
</body>
</html>
            
          
!
            
              body{
  box-sizing: border-box;
  background: url(https://kaboompics.com/cache/7/2/3/6/9/72369f841aa0c5afd94c619bc35e6b08d9fd738e.jpeg?version=v23) center no-repeat;
  background-size: cover;
  min-height: 100vh; //vertical height
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-family: Arial;
}
*, *:before, *:after {box-sizing: inherit;}

.container{
  background-color: rgba(130,138,117,0.7);
  color: black;
}

.recipeBtn {
 padding-top: 20px;
}

.card{
  background: black;
  border-radius: 50%;
  color: white;
  font-size: 1.2em;
  button{color: black}
}

h5, h4{background-color: lightblue}


.tableFooter{
  margin-top: 150px;
}
.footerSvg{
  width: 32px;
}
            
          
!
            
              var app = angular.module('recipeBoxApp', [])
 .controller('recipeBoxCtrl', function($scope) {
  
  // Create the initial recipe list from local storage. 
 $scope.saved = localStorage.getItem('_msecrist_recipebox');
  // If localstorage has a value for my key, grab that. If not, create a new local storage item.
	$scope.recipeList = (localStorage.getItem('_msecrist_recipebox')!==null) ? JSON.parse($scope.saved) : [{
   title: "Pizza",
   ingredients: "Cheese, Ham, Tomato"
  }, {
   title: "Ice-cream",
   ingredients: "Milk, Chocolate, Sugar"
  }, {
   title: "Cheesecake",
   ingredients: "Milk, cream, buscuits, sugar"
  }, {
   title: "Cake",
   ingredients: "Milk, eggs, vanilla, chocolate"
  }];
  // This could probably be in a function on its own, with how many times its called. But its just one line so I didn't bother.
	localStorage.setItem('_msecrist_recipebox', JSON.stringify($scope.recipeList));

  //Allow a user to add a recipe.
  $scope.addRecipe = function() {
   if ($scope.newRecipe != null && $scope.newIngredients != null) {
    //Push the recipe to the array of recipes, and then save that to localstorage.
    $scope.recipeList.push({
     title: $scope.newRecipe,
     ingredients: $scope.newIngredients
    })
    localStorage.setItem('_msecrist_recipebox', JSON.stringify($scope.recipeList));
    $scope.newRecipe = null;
    $scope.newIngredients = null;
   }
  }

  //Allow a user to delete a recipe.
  $scope.deleteRecipe = function(index) {
   //Show confirm alert box, and when user confirms, it cuts the recipe out of the array and then updates localstorage.
   if (confirm("This recipe is going to be deleted")) {
    $scope.recipeList.splice(index, 1)
    localStorage.setItem('_msecrist_recipebox', JSON.stringify($scope.recipeList));
   }
  }
  
  //Edit a recipe
  $scope.editRecipe = function(index) {
   //Grab the recipe by the index of the array and then display the recipe's ingredients in a prompt.
   //That allows the user to change ingredients. If they hit cancel, it returns a null response, so check for that.
   var ingredients = $scope.recipeList[index].ingredients
   var result = prompt("Edit the ingredients: ", ingredients)
   if(result != null){
    $scope.recipeList[index].ingredients = result;
    localStorage.setItem('_msecrist_recipebox', JSON.stringify($scope.recipeList));
   }
  }

 });

//jQuery for Collapsible area 
  $(document).ready(function(){
    $('.collapsible').collapsible();
  });
            
          
!
999px
Loading ..................

Console