- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有没有办法使用日期字符串格式限制 ng-repeat 中的显示?我正在尝试使表中的某些数据过期,例如:如果日期是 2019/03/22
.. 它不会显示在表中,因为它是上周的数据
angular.module('selectExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.register = {
regData: {
branch: {},
},
names: [
{name:"narquois",date:"2019/03/30"},
{name:"vorpal",date:"2019/03/28"},
{name:"keen",date:"2019/03/25"},
{name:"argol",date:"2019/03/18"},
{name:"long",date:"2019/03/17"},
{name:"propolis",date:"2019/03/16"}
],
};
}]);
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<div ng-app="selectExample" ng-controller="ExampleController">
<table id="example" width="100%">
<thead>
<tr align="center">
<th>Name</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="person in register.names">
<td align="center">{{ person.name }}</td>
<td align="center">{{ person.date }}</td>
</tr>
</tbody>
</table>
</div>
最佳答案
您可以创建一个自定义过滤器,您可以在其中获取一周的第一天和最后一天,并检查从数组传递的日期是否在该范围内。
js
$scope.filterCurrentWeek = function(row){
var today = new Date(); // get current date
var first = today.getDate() - today.getDay();
var last = first + 6;
var firstDay = new Date(today.setDate(first)).toUTCString();
console.log(firstDay)
var lastDay = new Date(today.setDate(last)).toUTCString();
console.log(lastDay)
var rowDate = new Date(row.date)
console.log(rowDate)
if(Date.parse(firstDay) <= Date.parse(rowDate) && Date.parse(lastDay) >= Date.parse(rowDate)){
return true;
}
else{
return false;
}
}
html
<table id="example" width="100%">
<thead>
<tr align="center">
<th>Name</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="person in register.names | filter: filterCurrentWeek">
<td align="center">{{ person.name }}</td>
<td align="center">{{ person.date }}</td>
</tr>
</tbody>
</table>
关于javascript - 使用 yyyy/mm/dd 格式以 ng-repeat 显示本周数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55430789/
我需要使用正则表达式验证格式为 dd/mm/yyyy 的日期字符串。 此正则表达式验证 dd/mm/yyyy,但不验证 31/02/4500 等无效日期: ^(0?[1-9]|[12][0-9]|3[
我需要检查给定字符串的日期。我得到的字符串不规则,我不想使用 Dateformat 或类似的东西。我试图避免出现多个异常。我需要 dd.MM.yyyy 和 MM.yyyy 和 yyyy 的正则表达式。
我想使用在这里找到的 jQuery 屏蔽输入插件 http://digitalbush.com/projects/masked-input-plugin/格式化日期。 我正在从数据库中提取数据以在页面
我正在尝试以更有效的方式根据当前日期找出当前财政年度(FY - 3 月至 4 月)。这是我到目前为止写的内容 public static void main(String[] args) {
我已经搜索了该网站,但没有找到接近我需要的答案。基本上我的日期正确显示为“2013-05-09”,但我想要的是“2013 年 3 月 19 日”或使其更好“3 月 19 日, 2013 年”。 请向我
我需要使用 C# 更改日期字符串的格式 来自:“06/16/2010”或“16/06/2010” 至:“2010-06-16” 你能帮我实现这个吗 谢谢 最佳答案 如果您已经将它作为 DateTime
我正在以 MMM-yyyy 格式从 View 中提交日期值,即“Apr-2019”作为字符串。我需要将字符串值转换为 .Net 支持的日期格式,如 dd-MM-yyyy 或 yyyy-MM-dd。这里
我有一个包含以下数据的平面文件 2/12/2016 2/3/2017 12/23/2017 04/23/2017 第一个是 M/dd/yyyy,第二个是 M/d/yyyy,其余日期格式为 MM/dd/
好吧,我已经和这个战斗了足够长的时间。我有一个正则表达式 ^(1[0-2]|0[1-9]|\d)\/(20\d{2}|19\d{2}|0(?!0)\d|[1-9]\d) 这将匹配 8/15、08/15
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Extending JavaScript's Date.parse to allow for DD/MM/Y
我有 json 对象列表,其中一个字段是日期。问题是日期在 json 中以不同的方式写入。 大多数看起来像: "publishedDate": "2005-01-28" "publishedDat
这个问题已经有答案了: Generate & parse "Year-Month" values in text from Java (1 个回答) 已关闭 7 年前。 我有一个变量: YearMon
我对日期格式有一个奇怪的问题。就像,我正在使用 jquery 日期选择器,它设置为格式 dd/mm/yy。因此,当我在该字段中填写 01/09/2015 时,它应该意味着日期是 2015 年 9 月
我有以下日期, 24/04/2019 13/05/2019 12/04/2019 我想删除年份并将这些日期转换为以下格式, 24/04 13/05 12/04 这不是仅用于输出我想在该日期执行加法或申
“YYYY”和“yyyy”之间的确切区别是什么。我读过 this link ,它指出 A common mistake is to use YYYY. yyyy specifies the calen
我有一个日期列,其中日期格式为 2010-04-14 在 SQL Server 中。有没有办法将日期格式检索为 14/04/2010 在选择语句中? 最佳答案 试试这个: SELECT CONVERT
我有这个正则表达式:(\d{4})\/(\d{2,4})\/?(\w{2})?这似乎工作正常,但我想避免以下情况,例如:我有一个字符串“2020/2000/WEEEE”并且它匹配它。 它匹配的其他错误
这是用户输入日期的代码:(它必须是我的日期选择器,但表单必须将日期字段作为文本提交 - 不要问) 提交时,我在 javascript 中调用验证逻辑。我附上了当我尝试输入 01/01/2001 作为用
我正在尝试以 YYYY-YY 格式提取会计日期字符串的最后一年 (YY)。例如,这个“1999-00”的最后一年是 2000 年。 当前代码似乎涵盖了除此之外的大多数情况。 import pandas
这个问题已经有答案了: 已关闭11 年前。 Possible Duplicate: Conversion of Date 我从对话框中获取的日期为:5-1-2012 - 作为字符串。 我需要将其转换为
我是一名优秀的程序员,十分优秀!