angularjs - ng-click 在按钮上不起作用(angularjs-django)
问题描述
我是 angularjs 的新手,无法弄清楚为什么 ng-click on a button 不起作用。我在下面粘贴代码。我正在使用 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;
});
};
解决方案
推荐阅读
- android - 为什么 GMSGroundOverlay 图标没有在 GoogleMaps 中填充其边界?
- clojurescript - 在 cljs 中导入时 ajax.edn 不可用
- mysql - MYSQL将UNC时间插入列中,但出现错误
- java - 使用 getter 方法时出现错误(HttpMessageNotWritableException:无法写入 JSON:bean 类的无效属性“”)
- git - Unity 和 Github 场景合并
- azure-cognitive-search - 索引合并后自动更新的字段
- javascript - 为什么 new Uint8ClampedArray 的 new ImageData 会创建黑白图像
- python - Write PIL image to EXR using OpenEXR in Python
- scrapy - 有没有办法在 scrapy 中的 reactor.run() 之后运行代码?
- algorithm - 一组替代算法中的最大非重叠间隔数?