我想从角js json中的json获得最大值和最小值:
{
"data":[
{
"name": "ranjith",
"age": 22
},
{
"name": "rahul",
"age": 20
},
{
"name": "jinesh",
"age": 25
},
{
"name": "vishnu",
"age": 24
}
]
}
Run Code Online (Sandbox Code Playgroud)
和我的控制器: -
var app = angular.module('myApp', ['']);
app.controller('myCtrl', function($scope, data) {
$scope.data = data.data;
$scope.min="";
$scope.max="";
};
});
Run Code Online (Sandbox Code Playgroud)
我想从数组中获取最小值和最大值,并将其存储在变量min和max中
我是 angular js 和 moment.js 的新手,我有以下代码,它给出了一周的开始日和结束日,例如 1 月 17 日至 1 月 23 日。但我希望在 1 月 17 日星期一以这种格式的所有 7 天。
我的代码
var currentDate,
weekStart,
weekEnd,
shortWeekFormat = 'MMMM Do';
function setCurrentDate(aMoment){
currentDate = aMoment,
weekStart = currentDate.clone().startOf('week'),
weekEnd = currentDate.clone().endOf('week')
}
setCurrentDate(moment());
$scope.currentWeek = function(){ return currentDate.format(shortWeekFormat); };
$scope.currentWeekStart = function(){ return weekStart.format(shortWeekFormat); };
$scope.currentWeekEnd = function(){ return weekEnd.format(shortWeekFormat); };
Run Code Online (Sandbox Code Playgroud)
HTML
<h2><i class="fa fa-arrow-left"></i>Week Of {{currentWeek()}}{{currentWeekStart()}}-{{currentWeekEnd()}}<i class="fa fa-arrow-right"></i></h2>
<button ng-click="prevWeek()">previous week</button>
<button ng-click="nextWeek()">next week</button>
Run Code Online (Sandbox Code Playgroud) <div class="main">
<div class="item"></div>
<div class="item active"></div>
<div class="item"></div>
<div class="item"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
现在我想要主要类的子类的数量,在这种情况下将是4但我想要在当前(活动类)之后的计数,这将是2.如何做到这一点?
JS:
var a = $('.main').find('.item').after('.active').length;
Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用"datepicker"插件,它设置为十年视图,我想禁用未来的日期,为此我使用了该maxDate选项,但它不起作用,我的代码:
$('#data_1 .input-group.date').datepicker({
todayBtn: "linked",
maxDate: "0",
keyboardNavigation: false,
forceParse: false,
calendarWeeks: true,
autoclose: true
});
Run Code Online (Sandbox Code Playgroud)
试过0和new Date
angularjs ×2
jquery ×2
bootstrap-4 ×1
date ×1
datepicker ×1
days ×1
html ×1
html5 ×1
maxdate ×1
momentjs ×1