AngularJS Simple Example

by Said Kossouri

HTML

<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<div ng-app ng-controller="LoginController">
     <table  border="1" id="mtable" class="table table-striped">
          <thead><tr>
              <td>Item</td>
              <td><button id="deleteColl">Ok</button></td>

            </tr></thead>

          <tbody><tr>
            <td>Some Item</td>
            <td><input type="text"/></td>

          </tr></tbody>

      </table><br/>
      <button ng-click="addRow()" id="irow">+ Row</button>
      <button ng-click="addCol()" id="icol">+ Column</button>
</div>

JavaScript

function LoginController($scope) {
	$scope.addRow = function () {
    $('#mtable tbody').append($("#mtable tbody tr:last").clone());
    $('#mtable tbody tr:last :checkbox').attr('checked',false);
    $('#mtable tbody tr:last td:first').html($('#row').val());
  }
      
  $scope.addCol = function () {
    $('#mtable tr').append($("<td>"));
    $('#mtable thead tr>td:last').html('<button ng-click="hello()">Hello!</button>');
    $('#mtable tbody tr').each(function(){$(this).children('td:last').append($('<input type="text">'))});	
  }  
  
  $scope.helle = function () {
  	alert("HELLO");
  }
            
}