javascript - 如何使用 AngularJS 调用函数 ng 单击已从 Grails Controller 渲染的模板

标签 javascript json angularjs grails angular-ng

how to call function using angularjs ng-click on template that has render from controller of grails. i have try this. but jquery function calling works well.. but ng-click() function not working..what wrong with me.i am battling with this.

我的 Controller 功能:

 $scope.editTasks = function(){
            console.log("uu");
        }

我的模板已在表内呈现代码:

<button class="table-icon editIcon" ng-click="editTasks()" /> 

最佳答案

您必须定义一个 Controller 并将按钮包装在其中:

HTML:

<div ng-controller="theCtrl">
    <button class="table-icon editIcon" ng-click="editTasks()" /> 
</div>

JS:

app.controller('theCtrl', function($scope) {
    $scope.editTasks = function(){
         console.log("uu");
    }
});

关于javascript - 如何使用 AngularJS 调用函数 ng 单击已从 Grails Controller 渲染的模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32549064/

相关文章:

javascript - 在 React/TypeScript 中渲染一组组件?

javascript - 如何在 Canvas 中绘制从页面加载的图像

python - 使用哪个 REST 动词?

android - 如果可以,我们能否将 Paypal 支付网关与 IONIC 1 或 2 应用程序集成,那么如何...?

javascript - Angular - 编译指令后无法访问 Controller 方法

javascript - 在javascript中动态生成新 Canvas

javascript - Javascript 中的单词边界匹配

c# - 如何处理同时返回字符串和字符串数组的json?

ios - If 语句输出两个参数而不是其中一个?

javascript - AngularJS 如何将 ng-model 绑定(bind)更改为另一个元素