ng-click在按钮上不起作用(angularjs-django)

时间:2019-03-23 09:58:22

标签: angularjs django

我是angularjs的新手,无法弄清楚为什么ng-click按钮不起作用。我在下面粘贴代码。我正在使用django服务器渲染页面。

HTML代码:

<body ng-controller="myController">

<div class="container-fluid" >
    <table class="col-xs-12-ls-12 mfPortfolioTable" width="100%">
        <tbody>
            <tr ng-repeat="x in records">
                <td class="search_table_cell col-xs-1-ls-1">{% verbatim %}{{ x.units | number:3 }}{% endverbatim %}</td>
            </tr>
            <tr>                
                <td><button class="btn btn-primary" ng-click="updateMfPortfolio()" id="updateFolio">Update</button></td>
            </tr>
        </tbody>
    </table>
</div>
</body>

控制器代码:

var app = angular.module('searchApp', []);
app.controller('myController', function($scope, $http) {
  $http.get('/somelink/').then(function(response){
      $scope.records = response.data.data;
  });

  //This is the function which I expect to get triggered by ng-click

  $scope.updateMfPortfolio = function(){
      console.log('Updating MF Portfolio...');
      $http.get('/somelink/').then(function(response){
          console.log('Code reached here...');
          $scope.records = response.data.data;
      });
  };

0 个答案:

没有答案