JSFiddle - React, Tailwind, and code Playground
by Kumar Ramalingam
HTML
<div ng-app>
<script>
/*
* ng-controller - ngtodo
* write all method definitation in controllers.
*/
function ngtodo($scope) {
//tasks array declaration.
$scope.tasks = [];
//add task method
$scope.addTask = function() {
$scope.tasks.push($scope.tasked); };
//check task method
$scope.checkTask = function(index) {
if(true) {
//delete button display use ng=show.
$scope.deleteTasks=true; } }
//onloading delete button hide use ng-show module.
$scope.deleteTasks=false;
//delete task method.
$scope.deleteTask = function(index) {
if(confirm("Are you sure to delete task?"))
{
$scope.tasked="";
$scope.tasks.splice(index,1); } } }
</script>
<div ng-controller="ngtodo">
<div class="offset4 span6 well">
<label>Enter Task</label>
<input ng-model="tasked" type="text"> <br/>
<ul class="unstyled">
<li ng-repeat="task in tasks">
<input type="checkbox" ng-click="checkTask()">{{task}}
</li>
</ul>
<button ng-click="addTask()">Add Task</button>
<button ng-click="deleteTask($index)" ng-show="deleteTasks">
Delete Task</button> <br/>
</div>
</div>
</div>