Skip to content

Instantly share code, notes, and snippets.

@amejiarosario
Created September 30, 2014 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amejiarosario/26751cb85d088fd59c28 to your computer and use it in GitHub Desktop.
Save amejiarosario/26751cb85d088fd59c28 to your computer and use it in GitHub Desktop.
A Pen by Adrian Mejia.
<!DOCTYPE html>
<html ng-app="app">
<head>
<title>test your ng-knowledge</title>
</head>
<body>
<div ng-view></div>
<!-- Libraries -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular-resource.min.js"></script>
<!-- Templates -->
<script type="text/ng-template" id="/todos.html">
<ul>
<input type="text" placeholder="Something to do..." ng-model="newTodo">
<button ng-click="save()">Add</button>
<br><br>
<li ng-repeat="todo in todos">
<input type="checkbox" ng-model="todo.completed" ng-change="update($index)">
<a ng-show="!isEditing[$index]" href="#/todo/{{todo._id}}">{{todo.title}}</a>
<button ng-show="!isEditing[$index]" ng-click="isEditing[$index] = true">edit</button>
<button ng-show="!isEditing[$index]" ng-click="remove($index)">remove</button>
<input ng-show="isEditing[$index]" type="text" ng-model="todo.title">
<button ng-show="isEditing[$index]" ng-click="update($index)">update</button>
<button ng-show="isEditing[$index]" ng-click="isEditing[$index] = false">cancel</button>
</li>
</ul>
</script>
<script type="text/ng-template" id="/todo.html">
<h1>{{todo.title}}</h1>
Completed: {{todo.completed}} <br>
Notes:
<textarea>{{todo.notes}}</textarea>
<br>
<button ng-click="save()">save</button>
<a href="#/todos">back</a>
</script>
<!-- ng-code -->
<script>
angular.module('app', ['ngRoute', 'ngResource'])
.factory('Todos', ['$resource', function ($resource) {
return null;
}])
.controller('TodosController', ['$scope', 'Todos', function ($scope, Todos) {
}])
.controller('TodoController', ['$scope', '$routeParams', 'Todos', function ($scope, $routeParams, Todos) {
}])
.config(['$routeProvider', function ($routeProvider) {
}]);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment