为什么我的ng-repeat没有输出结果

时间:2016-04-24 19:28:21

标签: angularjs angularjs-ng-repeat

为什么ng-repeat没有输出结果?

插入选项正常,但没有输出。 请帮我指出问题

<head>
<script>
    var syntaxFinder = angular.module('syntaxFinder',[]);


    syntaxFinder.controller('syntaxCtrl', function($scope, $http){
        loaddata();
        function loaddata(){
            $http.get('https://sheetsu.com/apis/v1.0/471f7802').success(function(data){
                $scope.autos = data.result;
                $scope.refresh = function() {
                    loaddata();
                };
            });
        }
    });

    syntaxFinder.controller('FormCtrl',function($scope,$http){

    $scope.SendData = function () {
        // use $.param jQuery function to serialize data from JSON 
        var data = $.param({
            applicatie: $scope.applicatie,
            locatie: $scope.locatie,
            beschrijving: $scope.beschrijving,
            code: $scope.code,
            inhoud: $scope.inhoud,         
        });

        var config = {
            headers : {
                'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
            }
        }

        $http.post('https://sheetsu.com/apis/v1.0/471f7802', data, config)
                        .success(function (data, status, headers, config) {
            $scope.PostDataResponse = data;


        })
        .error(function (data, status, header, config) {
            $scope.ResponseDetails = "Data: " + data +
            "<hr />status: " + status +
            "<hr />headers: " + header +
            "<hr />config: " + config;
            });
        };


});
</script>

</head>

<body ng-controller="syntaxCtrl">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <h2>Syntax Finder</h2>

                    <div class="form-group">
                        <label>Zoek op Inhoud: 
                            <input class="form-control" type="text" ng-model="search.inhoud" placeholder="Mysql register" />
                        </label><br/>
                    </div>

                <table class="table table-striped">
                    <tr>
                        <th>Applicatie</th>
                        <th>Locatie</th>
                        <th>Beschrijving</th>
                        <th>Code</th>
                        <th>Inhoud</th>
                    </tr>

                    <!--<tr ng-repeat="auto in autos | filter:search:strict | limitTo:10 ">-->

                    <tr ng-repeat="auto in autos | filter:search:strict | orderBy:'applicatie' ">  
                        <td>{{auto.applicatie}}</td>
                        <td>{{auto.locatie}}</td>
                        <td>{{auto.beschrijving}}</td>
                        <td>{{auto.code}}</td>
                        <td>{{auto.inhoud}}</td>      
                    </tr>
                </table>

                <div class="form-group">
                    <button ng-click="refresh()">Refresh</button>
                </div>
            </div>
        </div>
    </div>
</body>

1 个答案:

答案 0 :(得分:0)

这是你的问题解决了。用这个

更新你的js代码

这是fiddle

var myApp = angular.module('myApp',[]);

myApp.controller('syntaxCtrl', function($scope, $http){
function loaddata(){
    $http.get('https://sheetsu.com/apis/v1.0/471f7802').success(function(data){
        $scope.autos = data;
    });
}
$scope.refresh = function() {
    loaddata();
};
loaddata();

});
 myApp.controller('FormCtrl',function($scope,$http){

 $scope.SendData = function () {
   // use $.param jQuery function to serialize data from JSON 
    var data = $.param({
        applicatie: $scope.applicatie,
        locatie: $scope.locatie,
        beschrijving: $scope.beschrijving,
        code: $scope.code,
        inhoud: $scope.inhoud,
    });

    var config = {
        headers : {
            'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
        }
    }

    $http.post('https://sheetsu.com/apis/v1.0/471f7802', data, config)
    .success(function (data, status, headers, config) {
        $scope.PostDataResponse = data;
    })
    .error(function (data, status, header, config) {
        $scope.ResponseDetails = "Data: " + data +
            "<hr />status: " + status +
            "<hr />headers: " + header +
            "<hr />config: " + config;
    });
 };
 });