如何使用angularjs和asp.net重新加载ng-repeat数据

时间:2017-03-12 00:40:31

标签: javascript asp.net angularjs

如何将数据代码传递给angularjs变量。页面加载时工作正常。但是,当我单击按钮时,对于过滤数据。服务器端不加载数据。

  

$ scope.studentinformation =<%= studentattendancejson%>

<script type="text/javascript">
            var app = angular.module('myApp', []);
            app.controller('myCtrl', ['$scope', '$filter', function ($scope, $filter) {
                $scope.currentPage = 0;
                $scope.pageSize = 100;
                $scope.data = [];
                $scope.q = '';

                $scope.studentinformation = <%= studentattendancejson %>
                $scope.getData = function () {


                    return $filter('filter')($scope.studentinformation, $scope.q)

                }
                $scope.numberOfPages = function () {
                    return Math.ceil($scope.getData().length / $scope.pageSize);
                }


            }]);

            app.filter('startFrom', function () {
                return function (input, start) {
                    start = +start; //parse to int
                    return input.slice(start);
                }
            });

        </script>

 <tr ng-repeat="info in studentinformation| filter:q | startFrom:currentPage*pageSize | limitTo:pageSize">
                                                    <td>{{info.student_name}}</td>
                                                    <td>{{info.father_name}}</td>
                                                    <td>{{info.class_name}}</td>
                                                    <td>{{info.attendancedate | date:'dd-MM-yyyy'}}</td>
                                                    <td ng-if="info.attendanceType == 'Present'"> <button type="button" class="btn btn-success btn-circle"><i class="fa fa-check"></i></td>
                                                     <td ng-if="info.attendanceType == 'Absent'"> <button type="button" class="btn btn-danger btn-circle"><i class="fa fa-times"></i></td>
                                                     <td ng-if="info.attendanceType == 'Leave'"> <button type="button" class="btn btn-warning btn-circle"><i class="fa fa-list"></i></td>


                                                </tr>

// Angularjs变量

{{1}}

页面加载其工作正常 Page load its working fine

按钮点击按钮事件,它不显示数据,下面是结果 enter image description here

0 个答案:

没有答案