gpt4 book ai didi

javascript - AngularJS 与 Webix 集成,调用配置对象中定义的事件

转载 作者:行者123 更新时间:2023-12-03 12:40:38 25 4
gpt4 key购买 nike

我正在使用 Angular JS 和 Webix 构建一个应用程序。

如何调用在配置初始化中标记的函数(例如“accountSelected”),该函数在同一 Controller 的 Angular 范围中定义,

HTML:

<html xmlns:ng="http://angularjs.org&quot; ng-app="accountSearchApp">
<body ng-controller="searchController">
<div webix-ui="datatable_config" ></div>
</body>
</html>

脚本:

var accountSearchApp = angular.module('accountSearchApp', [ "webix" ]);

// defining controller
accountSearchApp
.controller("searchController", function($scope){

$scope.datatable_config = {
id: "dt_01",
view:"datatable",
columns:[
{id:"edit", header:["Choose", {
content:"textFilter", placeholder:"Type here to filter the grid",
compare:oneForAll, colspan:2
}], width:200, template:"<a href='javascript:void(0)' onclick='accountSelected()'>Select</a>"
},
{ id:"AccountName", header:["Account Name",null], width:300, sort:"string"},
],
data: arryObj
};

$scope.accountSelected = function(){
console.log(" SUCCESS ");
}
});

当函数 accountSelected 定义放置在 Controller 范围之外时能够调用,我需要它与 Controller 范围内定义的函数一起使用。

最佳答案

您可以用 js 函数替换内联 onclick 处理程序。像这样

columns:[
{ id:"edit", header:"Choose", width:200,
template:"<a href='javascript:void(0)' class='myLink'>Select</a>"
}
],
onClick:{
myLink:function(e, id){ $scope.accountSelected(id); }
}

关于javascript - AngularJS 与 Webix 集成,调用配置对象中定义的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23543438/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com