AngularJS日程表案例詳解
更新時(shí)間:2017年08月15日 09:21:21 作者:一顆快樂心
本文通過實(shí)例代碼給大家介紹了AngularJS日程表案例詳解,通過簡單代碼實(shí)現(xiàn)了添加事件/完成事件/刪除事件功能,具體代碼大家參考下本文
功能:添加事件/完成事件/刪除事件
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> *{ margin: 0; padding: 0; } .note{ margin:0 auto; background: orange; color: orange; width: 400px; padding:2px 2px; } .input{ text-align: center; } h1{ text-align: center; color:#fff; padding:10px 10px; } h5{ color: #fff; text-align: left; padding-left: 10px; } textarea{ width: 300px; height: 58px; resize: none; border:1px solid orange; } button{ width: 80px; height: 58px; outline: none; background: orange; font-size: 24px; border:3px solid #fff; position: relative; top:-22px; color: #fff; } ul li{ margin:0 auto; width: 380px; background: #fff; list-style: none; line-height:18px; padding:2px; margin-bottom:2px; } .delbtn{ background: skyblue; border:none; float: right; line-height:14px; color: #fff; padding:2px 6px; } .done label{ text-decoration:line-through ; } </style> </head> <body ng-app="demo"> <div class="note" ng-controller='democontroller'> <h1>NOTE</h1> <div class="input"> <textarea name="" id="" cols="30" rows="10" ng-model="text"></textarea><button ng-click="add()">提交</button> </div> <div class="todo"> <h5>未完成:{{todos.length}}</h5> <ul> <li ng-repeat="todo in todos"> <form> <input type="radio" id="redio" ng-checked="{{todo.checked}}" ng-click="doit($index)"> <label for="redio">{{todo.text}}</label> <input type="button" value="刪除" class="delbtn" ng-click="del($index,todos)"> </form> </li> </ul> </div> <div class="done"> <h5>已完成:{{dones.length}}</h5> <ul> <li ng-repeat="done in dones"> <form> <input type="radio" id="redio" ng-checked="{{done.checked}}" ng-click="notdoit($index)"> <label for="redio">{{done.text}}</label> <input type="button" value="刪除" class="delbtn" ng-click="del($index,dones)"> </form> </li> </ul> </div> </div> <script src="angular.min.js"></script> <script> var demo=angular.module('demo',[]); demo.controller('democontroller',function($scope){ $scope.todos=[]; $scope.dones=[]; $scope.add=function(){ $scope.todos.push({ checked:false, text:$scope.text }); $scope.text='';//清空文本框 console.log($scope.todos.length); } $scope.doit=function(index){ var str=$scope.todos.splice(index,1)[0]; str.checked=true; $scope.dones.push(str); } $scope.notdoit=function(index){ var str=$scope.dones.splice(index,1)[0]; str.checked=false; $scope.todos.push(str); } $scope.del=function(index,arr){ arr.splice(index,1); } }); </script> </body> </html>
總結(jié)
以上所述是小編給大家介紹的AngularJS日程表案例詳解,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
您可能感興趣的文章:
- Angular.js與Bootstrap相結(jié)合實(shí)現(xiàn)表格分頁代碼
- 詳細(xì)分析使用AngularJS編程中提交表單的方式
- AngularJS實(shí)現(xiàn)表單手動(dòng)驗(yàn)證和表單自動(dòng)驗(yàn)證
- 詳解AngularJS中的表格使用
- AngularJS實(shí)現(xiàn)數(shù)據(jù)列表的增加、刪除和上移下移等功能實(shí)例
- AngularJS表單編輯提交功能實(shí)例
- angular實(shí)現(xiàn)表單驗(yàn)證及提交功能
- AngularJS實(shí)現(xiàn)表格的增刪改查(僅限前端)
- 如何用angularjs制作一個(gè)完整的表格
- 使用angularjs創(chuàng)建簡單表格
- Angular實(shí)現(xiàn)的日程表功能【可添加及隱藏顯示內(nèi)容】
相關(guān)文章
Commands Queries設(shè)計(jì)模式提高Angular應(yīng)用性能及可維護(hù)性
在Angular應(yīng)用開發(fā)領(lǐng)域,Commands and Queries 設(shè)計(jì)模式是一個(gè)關(guān)鍵的概念,它有助于有效地管理應(yīng)用程序的狀態(tài)和與后端的交互,本文將深入探討這一設(shè)計(jì)模式的核心要點(diǎn),并通過實(shí)際示例來加以說明2023-10-10angularjs實(shí)現(xiàn)多張圖片上傳并預(yù)覽功能
這篇文章主要為大家詳細(xì)介紹了angularjs實(shí)現(xiàn)多張圖片上傳并預(yù)覽功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02淺析Angular 實(shí)現(xiàn)一個(gè)repeat指令的方法
這篇文章主要介紹了Angular 實(shí)現(xiàn)一個(gè)repeat指令的方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-07-07angular實(shí)現(xiàn)導(dǎo)航菜單切換
這篇文章主要為大家詳細(xì)介紹了angular實(shí)現(xiàn)導(dǎo)航菜單切換,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03