无法使用Angularjs + Ajax进行绑定

时间:2016-02-02 11:05:35

标签: jquery angularjs ajax

我无法将结果绑定到html表。通过ajax调用我能够获得值。请查看我的代码,这样你就可以了解我想要做什么。

  var app = angular.module("myApp", []);
             app.controller("myCntrl", function ($scope, $http) {
                 $scope.ProductList = [];
                 $scope.fillProductList = function () {
                 var httpreq = {
                     method: 'POST',
                     url: "Try2.aspx/DistrictAnalysis",
                     headers: {
                         'Content-Type': 'application/json; charset=utf-8',
                         'dataType': 'json'
                     },
                     data: {}
                 }
           
                 $http(httpreq).success(function (response) {
                     $scope.ProductList = response.d;
            
                 })
             };
         });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div class="col-sm-8" ng-app="myApp" ng-controller="myCntrl">
       <a href="#xyz" ng-click="fillProductList()">
         </a>
   </div>
<table>
                            <tr>
                                <th>city</th>
                                <th>DevelopmentPercentage</th>
                              
                            </tr>
                             <tr   ng-repeat="product in ProductList">
                                <td>{{product.City}}</td>
                                <td>{{product.DevelopmentPercentage}}</td>
                                
                           </tr>
                        </table>

`

0 个答案:

没有答案