Created
March 19, 2015 16:10
-
-
Save fredchu/c0a1f64b729720b543e0 to your computer and use it in GitHub Desktop.
Demo AngularJS
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 ng-app="todoApp"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Pinkoi Dev Sharing AngularJS Demo</title> | |
| <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> | |
| </head> | |
| <body ng-controller="todoController"> | |
| <h1>Todos count: <span>{{todos.length}}</span></h1> | |
| <ul id="list"> | |
| <li ng-repeat="todo in todos">{{todo}}</li> | |
| </ul> | |
| <form id="form-todo" ng-submit="addTodo($event)"> | |
| <input id="form-input" ng-model="todoContent" type="text"> | |
| <input type="submit" value="Add a Todo"> | |
| </form> | |
| <script> | |
| angular.module('todoApp', []) | |
| .controller('todoController', ['$scope', function($scope) { | |
| $scope.todos = [ | |
| 'test' | |
| ]; | |
| $scope.addTodo = function($event) { | |
| $event.preventDefault(); | |
| if (!$scope.todoContent) { | |
| return false; | |
| } | |
| $scope.todos.push($scope.todoContent); | |
| $scope.todoContent = ''; | |
| }; | |
| }]); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment