JSFiddle - React, Tailwind, and code Playground

by kiran prasad

HTML

<div ng-app="myApp"> 
    <div ng-controller="MyCtrl">
  <input ng-model="newitem">
  <button ng-click='add()'>Add</button>
  <br/>
  <b>Items Added Below</b>
  <div ng-repeat='item in items'>
    <input ng-model='item' id='item-{{$index}}' class='input-{{$index}}'/>
    <button ng-click='del($index)'>DEL</button>
  </div>
</div>
</div>

JavaScript

var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
  $scope.items = [];
  $scope.newitem = '';
  $scope.add = function(){
  alert($scope.items.length)
    if ($scope.items.length < 4) {
      $scope.items.push($scope.newitem);
    }
  }
  $scope.del = function(i){
    $scope.items.splice(i,1);
  }
}