I have a datatable being generated by JSON array coming from a specific url. I also have a hypderlink on each column that redirects me to the next page either.
Now all I have to do is to call another function from inside the same angularjs controller.
Code for DataTable, with hyperlink columns, PLEASE REFER TO THE if BLOCK for concerned citation:
$.getJSON('http://blahblahblah/company/all', function(data) {
var companyId = null;
$('#companies').DataTable({
"aaData": data,
"aoColumns": [
{"mDataProp":"companyId", "render": function(data, type, row, meta) {
if( type==='display' ) {
companyId = data;
data = '<a href="' + "/pages/company?companyId=" +companyId+ '">' + data + '</a>';
// call a function from this file when click on the above generated link, JUST HERE
}
return data;
}},
{"mDataProp":"legalName", "render": function(data, type, row, meta) {
if( type==='display' ) {
data = '<a href="' + "/pages/company?companyId=" +companyId+ '">' + data + '</a>';
// call a function from this file when click on the above generated link, JUST HERE
}
return data;
}}
]
});
});
Code for a function defined in the same controller:
$scope.findCompanyById = function() {
$http.get(
'http://blahblahblah/company/find?id='
+ $location.search().companyId).
then(function(response) {
$scope.company.companyInfo = response.data;
});
};
I am waiting for your kind response, Thanks.