This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul class="list-group"> | |
<li class="list-group-item clearfix task"> | |
<p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod | |
tempor incididunt ut labore et dolore magna aliqua.</p> | |
<div> | |
<span class="pull-right"> | |
<button class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></button> | |
<button class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-ok"></span></button> | |
<button class="btn btn-primary btn-xs"><span class="glyphicon glyphicon-repeat"></span></button> | |
<button class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove"></span></button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="form"> | |
<div class="input-group"> | |
<input type="text" class="form-control"> | |
<span class="input-group-btn"> | |
<button class="btn btn-default" type="button"> | |
<span class="glyphicon glyphicon-plus"></span> Add Task</button> | |
</span> | |
</div> | |
</div> | |
<hr/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body ng-app="toDoApp"> | |
<div class="container" ng-controller="ToDoController"> | |
<div class="col-xs-12 col-sm-12 col-md-offset-3 col-md-5 col-lg-offset-3 col-lg-5"> | |
<h2>ToDo App</h2> | |
<!-- Form Starts Here --> | |
<div class="form"> | |
<div class="input-group"> | |
<input type="text" class="form-control" ng-model="task"> | |
<span class="input-group-btn"> | |
<button class="btn btn-default" type="button" ng-click="addTask()"><span |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Task List Starts Here --> | |
<ul class="list-group" ng-show="tasks.length > 0"> | |
<li class="list-group-item clearfix task" ng-repeat="todo in tasks" ng-class="{disabled: todo.done}"> | |
<p class="lead">{{todo.task}}</p> | |
<div> | |
<span class="pull-right"> | |
<button class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil" | |
ng-click="editTask($index)"></span></button> | |
<button class="btn btn-primary btn-xs" ng-show="!todo.done"><span class="glyphicon glyphicon-ok" | |
ng-click="doneTask($index)"></span></button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.tasks = []; | |
$scope.editIndex = false; | |
$scope.addTask = function () { | |
if( $scope.editIndex === false){ | |
$scope.tasks.push({task: $scope.task, done: false}) | |
} else { | |
$scope.tasks[$scope.editIndex].task = $scope.task; | |
} | |
$scope.editIndex = false; | |
$scope.task = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.editTask = function (index) { | |
$scope.task = $scope.tasks[index].task; | |
$scope.editIndex = index; | |
} | |
$scope.doneTask = function (index) { | |
$scope.tasks[index].done = true; | |
} | |
$scope.unDoneTask = function (index) { | |
$scope.tasks[index].done = false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('toDoApp', []); | |
app | |
.controller('ToDoController', ['$scope', function ($scope) { | |
$scope.tasks = []; | |
$scope.editIndex = false; | |
$scope.addTask = function () { | |
if( $scope.editIndex === false){ | |
$scope.tasks.push({task: $scope.task, done: false}) | |
} else { | |
$scope.tasks[$scope.editIndex].task = $scope.task; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular | |
.module('storageModule', []) | |
.factory('store',['$window', function($window){ | |
return { | |
setLocal: function( key, value ){ | |
try{ | |
if( $window.Storage ){ | |
$window.localStorage.setItem(key, value); | |
return true; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular | |
.module('storageModule', []) | |
.factory('store',['$window', function($window){ | |
return { | |
setLocal: function( key, value ){ | |
//code to store the key & value pair in localStorage | |
}, | |
getLocal: function( key ){ | |
//code to get the key stored in localStorage | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if( window.Storage ){ | |
/* | |
* Get the values previously stored | |
*/ | |
//get the `user` key stored in the session storage | |
//this will show the value if stored otherwise 'undefined' | |
console.log( sessionStorage.getItem('user') ); | |
//get the `user` key stored in the local storage | |
//this will give 'undefined' | |
console.log( localStorage.getItem('user') ); |