


Detailed explanation of Angular's implementation of schedule function (can add and hide display content)
This article mainly introduces the schedule function implemented by Angular, with the function of adding content to the schedule and hiding the displayed content, and involves implementation techniques related to AngularJS event response and dynamic operation of page elements. Friends in need can refer to it. I hope Can help everyone.
The example in this article describes the schedule function implemented by Angular. Share it with everyone for your reference, the details are as follows:
Let’s take a look at the running effect first:
The specific code is as follows:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>www.jb51.net Angular日程表</title> <style> table{ border-collapse: collapse; } td{ padding: 10px; border: 1px solid #000; } </style> <script src="angular.min.js"></script> <script> /* 1、基本布局 2、准备模拟数据 */ // 模拟数据 var data = { user:"吴四", items:[ {action:"约刘诗诗吃饭",done:false}, {action:"约刘诗诗跳舞",done:false}, {action:"约刘诗诗敲代码",done:true}, {action:"约刘诗诗爬长城",done:false}, {action:"约刘诗诗逛天坛",done:false}, {action:"约刘诗诗看电影",done:false} ] }; var myapp=angular.module("myapp",[]); /*这里的是自定义过滤器,将数组items 过滤之后返回arr*/ myapp.filter("doFilter",function(){ /*传入两个参数,一个数组items,另一个是complate*/ return function(items,flag){ var arr=[]; /*遍历items,如果dones是false或者下边的按钮在选中状态,就将这一条item push到arr中*/ for(var i=0;i<items.length;i++){ if(items[i].done==false){ arr.push(items[i]); }else{ if(flag==true){ arr.push(items[i]); } } } return arr; } }); myapp.controller("myCtrl",function($scope){ $scope.data=data; $scope.complate=false; /*判断还有几件事儿没有完成*/ $scope.count=function(){ var n=0; /*判断还有几件事儿没有完成*/ for(var i=0;i<$scope.data.items.length;i++){ if($scope.data.items[i].done==false){ n++; } } return n; }; /*添加新的日程*/ $scope.add=function(){ /*对$scope.action进行一下非空判断*/ if($scope.action){ /*如果输入了内容之后,就在数组的最后加入一条新内容*/ $scope.data.items.push({"action":$scope.action,"done":false}); /*添加完成之后,将input置空*/ $scope.action=""; } }; }); </script> </head> <body ng-app="myapp" ng-controller="myCtrl"> <h2>吴四的日程<span ng-bind="count()"></span></h2> <p> <input type="text" ng-model="action"><button ng-click="add()">添加</button> </p> <table> <thead> <tr> <th>序号</th> <th>日程</th> <th>完成情况</th> </tr> </thead> <tbody> <tr ng-repeat="item in data.items|doFilter:complate"> <td>{{$index}}</td> <td>{{item.action}}</td> <td><input type="checkbox" ng-model="item.done"></td> </tr> </tbody> </table> <p>显示全部<input type="checkbox" ng-model="complate"></p> </body> </html>
Related Recommended:
PHP development and production of a simple activity schedule Calendar
Detailed examples of Angular implementation of more complex table filtering and deletion functions
The above is the detailed content of Detailed explanation of Angular's implementation of schedule function (can add and hide display content). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

When buying a computer, we may not necessarily choose a large hard drive. At this time, if we want to add a new hard drive to win11, we can first install the new hard drive we purchased, and then add partitions to the computer. Tutorial on adding a new hard drive in win11: 1. First, we disassemble the host and find the slot of the hard drive. 2. After finding it, we first connect the "data cable", which usually has a fool-proof design. If it cannot be inserted, just reverse the direction. 3. Then insert the new hard drive into the hard drive slot. 4. After inserting, connect the other end of the data cable to the computer's motherboard. 5. After the installation is completed, you can put it back into the host and turn it on. 6. After booting, we right-click "This Computer" and open "Computer Management" 7. After opening, click "Disk Management" in the lower left corner 8. Then on the right you can

Many users are increasingly favoring the electronic ecosystem of Xiaomi smart home interconnection in modern life. After connecting to the Mijia APP, you can easily control the connected devices with your mobile phone. However, many users still don’t know how to add Mijia to their homes. app, then this tutorial guide will bring you the specific connection methods and steps, hoping to help everyone in need. 1. After downloading Mijia APP, create or log in to Xiaomi account. 2. Adding method: After the new device is powered on, bring the phone close to the device and turn on the Xiaomi TV. Under normal circumstances, a connection prompt will pop up. Select "OK" to enter the device connection process. If no prompt pops up, you can also add the device manually. The method is: after entering the smart home APP, click the 1st button on the lower left

Angular.js is a freely accessible JavaScript platform for creating dynamic applications. It allows you to express various aspects of your application quickly and clearly by extending the syntax of HTML as a template language. Angular.js provides a range of tools to help you write, update and test your code. Additionally, it provides many features such as routing and form management. This guide will discuss how to install Angular on Ubuntu24. First, you need to install Node.js. Node.js is a JavaScript running environment based on the ChromeV8 engine that allows you to run JavaScript code on the server side. To be in Ub

Do you know Angular Universal? It can help the website provide better SEO support!

With the rapid development of the Internet, front-end development technology is also constantly improving and iterating. PHP and Angular are two technologies widely used in front-end development. PHP is a server-side scripting language that can handle tasks such as processing forms, generating dynamic pages, and managing access permissions. Angular is a JavaScript framework that can be used to develop single-page applications and build componentized web applications. This article will introduce how to use PHP and Angular for front-end development, and how to combine them

In win11, we can quickly start software or files on the desktop by adding desktop shortcuts, and we only need to right-click the required files to operate. Add a desktop shortcut in win11: 1. Open "This PC" and find the file or software you want to add a desktop shortcut to. 2. After finding it, right-click to select it and click "Show more options" 3. Then select "Send to" - "Desktop Shortcut" 4. After the operation is completed, you can find the shortcut on the desktop.

Tampermonkey Chrome extension is a user script management plug-in that improves user efficiency and browsing experience through scripts. So how does Tampermonkey add new scripts? How to delete the script? Let the editor give you the answer below! How to add a new script to Tampermonkey: 1. Take GreasyFork as an example. Open the GreasyFork web page and enter the script you want to follow. The editor here chooses one-click offline download. 2. Select a script. , after entering the script page, you can see the button to install this script. 3. Click to install this script to come to the installation interface. Just click here to install. 4. We can see the installed one-click in the installation script.

How to add watermark to images in Vue? Vue is a popular JavaScript framework that is widely used for building web applications. Sometimes we need to add watermarks to images in Vue applications to protect the copyright of the image or increase the recognizability of the image. In this article, I will introduce you to a method of adding watermarks to images in Vue and provide corresponding code examples. The first step is to introduce a third-party library for adding watermarks to Vue. It is recommended to use watermarkj
