Created
July 17, 2012 08:41
-
-
Save lalabear/3128097 to your computer and use it in GitHub Desktop.
邊學AngularJS邊做Todo List 第二回
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
function TodoCrtl($scope) { | |
$scope.newItem = ''; | |
$scope.todoList = []; | |
$scope.addItem = function(){ | |
if(this.newItem){ | |
this.todoList.push({label:this.newItem}); | |
this.newItem = ''; | |
} | |
} | |
} |
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> | |
<head> | |
<meta charset="utf-8"> | |
<title>邊學AngularJS邊做Todo List (2)</title> | |
<script type="text/javascript" src="http://code.angularjs.org/angular-1.0.1.min.js"></script> | |
<script type="text/javascript" src="js/controllers.js"></script> | |
</head> | |
<body ng-controller="TodoCrtl"> | |
<h1>Todo List</h1> | |
<form ng-submit="addItem()"> | |
<input type="text" ng-model="newItem" name="newItem" /> | |
<input type="submit" id="submit" value="新增待辦事項" /> | |
</form> | |
<ul> | |
<li ng-repeat="item in todoList">{{item.label}}</li> | |
</ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment