Created
July 13, 2017 22:55
-
-
Save SyNeto/75e62e69c3c9ea87da3310db4513136d to your computer and use it in GitHub Desktop.
Woooo
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="es-MX"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<div ng-app="todoApp" ng-controller="todoController as todoCtrl"> | |
<div> | |
<label for="add-task">Task</label> | |
<input type="text" ng-model="taskText"> | |
<button ng-click="addTask(taskText)">Add Task</button> | |
</div> | |
<div> | |
<ul> | |
<li ng-repeat="task in tasks" ng-click="onClick()"> | |
<input type="checkbox" ng-model="task.done" ng-change="tasks.$save(task)"> {{ task.text }} | |
</li> | |
</ul> | |
</div> | |
</div> | |
<!-- Scripts --> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> | |
<script src="https://www.gstatic.com/firebasejs/3.8.0/firebase.js"></script> | |
<script src="https://cdn.firebase.com/libs/angularfire/2.3.0/angularfire.min.js"></script> | |
<script> | |
(function(){ | |
var todoApp = angular.module('todoApp', ['firebase']); | |
todoApp.config(function(){ | |
var config = { | |
apiKey: "AIzaSyDmm1M7DO59la5mo7Rt1w9epvm_DkvO-vQ", | |
authDomain: "foo1-ae9db.firebaseapp.com", | |
databaseURL: "https://foo1-ae9db.firebaseio.com", | |
}; | |
firebase.initializeApp(config); | |
}); | |
todoApp.controller('todoController', ['$scope', '$firebaseArray', function($scope, $firebaseArray){ | |
var tasksRef = firebase.database().ref('tasks'); | |
var tasks = $firebaseArray(tasksRef); | |
$scope.tasks = tasks; | |
$scope.addTask = function(taskText){ | |
$scope.tasks.$add({ text: taskText, done: false }); | |
$scope.taskText = ''; | |
} | |
}]); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment