web page Hi guys, I am writing some JavaScript code in the script element on a PUG file, how can I access the data (client_list, see below code) that transferred from the Controller, Thanks!
extends layout
block content
// here the client_list can be accessed
- client_list.sort(function(a, b) {let textA = a.company_name.toUpperCase(); let textB = b.company_name.toUpperCase(); return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;});
input(type='text', id='search_content')
button(type='button', id='search_button') Search
hr
table(id='product_css')
tr
th Company Name
th Person Name
each client in client_list
tr
td #{client.company_name}
td #{client.person_name}
script(type='text/javascript').
$(document).ready(function() {
const content = $('#search_content').val();
// where client_list is undefined
client_list.forEach(function(client, index, array) {
console.log(client, index)
})
});