在angularjs $ scope

时间:2016-11-07 11:08:37

标签: javascript jquery angularjs

我正在创建一个网络应用,我需要查看不同日期的数据取决于按钮点击

我有3个按钮

<button type="button" class="btn btn-info" ng-model="today" ng-click="prevbutton()">previous</button>
<button type="button" class="btn btn-info" ng-model="today" ng-click="tod()">Today</button>
<button type="button" class="btn btn-info" ng-model="nextbuttons" ng-click="nextbutton()">Next</button>
  

上一个按钮会显示前几天的数据取决于多少   单击它的时间(如果点击一次,它将显示昨天的数据,如果   两次,然后是几天之前的数据)它工作正常

     

现在按钮将显示今天的数据并且它也正常工作

下一个按钮将显示即将到来的日期数据,现在概率是下一个按钮,如果我点击下一步它将显示明天的数据,如果我再次点击下一步它将跳转到10天后的日期明天(that is if i click once it will show me data of 8th if i click twice it is jumping to 18)但是一旦我点击了上一个按钮,然后我点击了下一个按钮,它会正确显示数据(that is if i click once it will show me data of 8th and if i clicked twice it will show me data of 9th

这是我的js

$scope.tod = function () {
            $scope.button = "0";
            $http.get('/Models/welcome.asmx/welcomegrid', {
                params:
                {
                    log: 'admin',
                    pm: 'admin',
                    button: $scope.button
                }
            })
       .then(function (response) {
           $scope.welcometable = response.data.welcome;
           console.log(response.data.welcome);
       })
        }

        $scope.nextbutton = function () {
            $scope.button = $scope.button + 01;
            $http.get('/Models/welcome.asmx/welcomegrid', {
                params:
                {
                    log: 'admin',
                    pm: 'admin',
                    button: $scope.button
                }
            })
       .then(function (response) {
           $scope.welcometable = response.data.welcome;
           console.log(response.data.welcome);
       })
        }

        $scope.prevbutton = function () {
            $scope.button = $scope.button - 1;
            $http.get('/Models/welcome.asmx/welcomegrid', {
                params:
                {
                    log: 'admin',
                    pm: 'admin',
                    button: $scope.button
                }
            })
       .then(function (response) {
           $scope.welcometable = response.data.welcome;
           console.log(response.data.welcome);
       })
        }

需要你的帮助

0 个答案:

没有答案