1 Star 0 Fork 0

LiShixi / pim

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
todolist-angularjs.html 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
<!DOCTYPE html>
<html ng-app="todo">
<head>
<title>TodoList</title>
<script src="../angular.min.js"></script>
<script type="text/javascript">
var todoModule=angular.module('todo',[]);
todoModule.controller('cc',function($scope){
$scope.input={title:'',fulfil:false};
$scope.editOrAdd = "Add";
$scope.currIndex=0;
$scope.todos=[
{fulfil:true,title:'test1'},
{fulfil:false,title:'test2'},
{fulfil:false,title:'test3'}
];
$scope.add=function(){
if($scope.input.title.length==0){
return;
}
if($scope.editOrAdd == "Modify"){
if($scope.currIndex < 0){
alert("currIndex less zero.")
return;
}
index=$scope.currIndex;
$scope.todos[index]={title:$scope.input.title,fulfil:$scope.input.fulfil};
$scope.input={title:'',fulfil:false};
$scope.editOrAdd = "Add";
$scope.currIndex= -1 ;
}else if($scope.editOrAdd == "Add"){
var title=$scope.input.title;
$scope.todos.push({title:title,fulfil:false});
$scope.input.title='';
}
}
$scope.remove=function(index){
$scope.todos.splice(index,1);
}
$scope.modify=function(index){
$scope.input=$scope.todos[index];
$scope.editOrAdd="Modify";
$scope.currIndex=index;
}
})
</script>
<style type="text/css">
.fulfil{
color:gray;
text-decoration: line-through;
}
</style>
</head>
<body >
<div ng-controller='cc'>
<h1>TODO:</h1>
<input ng-model="input.title">
<button ng-click='add()'>{{editOrAdd}}</button>
<div ng-repeat='todo in todos'>
<input type="checkbox" ng-model='todo.fulfil' >
<span ng-class={fulfil:todo.fulfil} ng-dblclick='modify($index)'>{{todo.title}}</span>
<button ng-click='remove($index)'>Delete</button>
</div>
</div>
</body>
</html>
Java
1
https://gitee.com/loyy77/pim.git
git@gitee.com:loyy77/pim.git
loyy77
pim
pim
master

搜索帮助