这有什么问题。我的params没有从我的datepicker获得价值!我需要有一个datepicker输入选项,我需要将其作为参数发送到最终被发送到c#paramaeter的参数。
<div layout="column">
<md-content md-primary>
<md-toolbar layout="flex">
<button ng-click="toggleSidenav('left')" class="menuBtn">
<span class="visually-hidden">Menu</span>
</button>
<h1>selling Order History</h1>
</md-toolbar>
<div layout="row" style="height:100%" flex>
<md-sidenav layout="column" ng-class="lockedOpen" class="md-closed md-sidenav-left md-whiteframe-z2" md-component-id="left">
<div>
</div>
</md-sidenav>
<md-content ng-controller="sellingListCtrl" layout="column" flex class="md-padding">
<md-tabs class="md-primary clearfix" md-selected="0" flex>
<md-tab label="selling Orders">
<input type="date" ng-model="filter.fromDate" />
<input type="date" ng-model="filter.toDate" />
...
这是.js文件
var sellingApp = angular.module('sellingApp', ['ngMaterial', 'ui.router', 'angularMoment', 'breeze.directives', 'breeze.angular', 'ui.bootstrap.pagination']).run(['breeze', function (breeze) { }]);;
sellingApp.controller('sellingListCtrl', [
'$scope', '$filter', '$location', 'breeze','sellingService',
function ($scope, $filter, $location, breeze, sellingService) {
$scope.pageLoaded = true;
$scope.lists = [];
$scope.loadselling = function () {
$scope.pageLoaded = false;
$scope.filter = {};
//$scope.filter.fromDate = "1/1/2015";
//$scope.filter.toDate = "1/1/2015";
sellingService.salesstatus($scope.filter).then(function (data) {
$scope.lists = data;
$scope.totalItems = data.totalItems;
if (data!=null) {
$scope.pageLoaded = true;
}
});
}
//$scope.init();
}
]);
sellingApp.factory('sellingService', ['$filter','$http', function ($filter, $http) {
function salesstatus(filter) {
var f = filter;
console.log(breeze);
return $http({
method: 'GET',
url: '/Services/SalesStatus',
params: { fromDate: f.fromDate, toDate: f.toDate, sParts: true }
}).then(function (result)
{ return result.data; })
//.catch(function (s) { console.log(s); });
}
return {
salesstatus: salesstatus
};
}]);
答案 0 :(得分:0)
您应该在$scope.filter
之外初始化$scope.loadselling
:
sellingApp.controller('sellingListCtrl', [
'$scope', '$filter', '$location', 'breeze','sellingService',
function ($scope, $filter, $location, breeze, sellingService) {
$scope.pageLoaded = true;
$scope.lists = [];
$scope.filter = {
fromDate: '',
toDate: ''
};
$scope.loadselling = function () {
$scope.pageLoaded = false;
sellingService.salesstatus($scope.filter).then(function (data) {
$scope.lists = data;
$scope.totalItems = data.totalItems;
if (data!=null) {
$scope.pageLoaded = true;
}
});
}
//$scope.init();
}
]);