我有以下
index.cshtml
<td>From:<input kendo-date-picker ng-model="date1" class="form-control input-sm" /></td>
<td>To:<input kendo-date-picker ng-model="date2" class="form-control input-sm" /></td>
<tr dir-paginate="item in AllItems| itemsPerPage: 15 | filter : dateRangeFilter:date1:date2"> @*filter : SearchSubmitDate | filter : MarketingSearch filter: dateRangeFilter('SubmitDate', startDate, endDate)*@
<td style="font-weight:bold;">{{item.MarketingFormattedID}}</td>
<td filter="{ 'SubmitDate': 'text' }">{{item.SubmitDate| mydate | date: 'MM/dd/yyyy'}}</td>
<td>{{item.DueDate| mydate | date: 'MM/dd/yyyy'}}</td>
<td>{{item.Description}}</td>
<td>{{item.SubmittedBy}}</td>
<td>{{item.MarketingStatusTypeName}}</td>
<td>{{item.AssignedTo}}</td>
<td><button ng-click="GetByMktId(item.MarketingID)"> Edit</button></td>
</tr>
.js文件 中的
function parseDate(input) {
return Date.parse(input);
}
app.filter("dateRangeFilter", function () {
return function (items, from, to) {
console.log('dateRangeFilter ' + from + ' ' + to);
var df = parseDate(from);
var dt = parseDate(to);
console.log('parsed ' + df + ' ' + dt);
var result = [];
for (var i = 0; i < items.length; i++) {
var date_bet = items[i].datetime;
if (date_bet > df && dt > date_bet) {
result.push(items[i]);
}
}
return result;
};
});
一切都是未定义的。我对angularjs相对较新,并尝试了我在stackoverflow或google上找到的所有不同方式。不知道我错过了什么。请帮忙。谢谢。
其他信息: 它是一个非常大的控制器,所以我没有包含所有信息。
app.controller('cvManageMarketingController', function ($scope, serviceMarketing, updateMarketingItemService, marketingItemsListService,
serviceNewMarketCode, serviceSaveMktFiles, serviceGetMktFiles, serviceDownloadMktFile, $filter){
marketingItemsListService.getAll().then(function (value) {
$scope.AllItems = (value);
$scope.orderByField = 'SubmitDate';
$scope.reverseSort = true;
$scope.AllFiles = [];
$scope.MarketingID = 0;
$scope.MarketingFormattedID = "";
$scope.Headers = "Add Marketing Item";
});
}
我将ng-controller =“cvManageMarketingController”传递给主div。