0

I'm building an application with Angular JS and Webix.

How to invoke function (say "accountSelected" ) marked in config initialization which is defined in angular scope of same controller,

HTML :

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

SCRIPT :

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 ");
    }
});

Am able to invoke when function accountSelected definition is placed outside of controller scope, I need it working with function defined inside controller scope.

Matt Rowe
  • 3
  • 2

1 Answers1

1

You can replace inline onclick handler, with js function. Like this

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); }
}
Roman V.
  • 298
  • 1
  • 4