I make from my database a json string and i want to pass it to my javascript function, and print it into a html table. I use angular to make it easy to print the table, but i don't know how can i sent the data from java to javascript. These is what i tried in java.
public void jsonRetr (String numeRepo) throws SQLException {
String sql = "SELECT * FROM " + numeRepo;
PreparedStatement prStm = (PreparedStatement) conn.prepareStatement(sql);
ResultSet rs = prStm.executeQuery(sql);
ArrayList<PersoaneJSON> persoane = new ArrayList<PersoaneJSON>();
while (rs.next()) {
String id = rs.getString("id");
String login_name = rs.getString("login_name");
String email = rs.getString("email");
String public_gits = rs.getString("public_gits");
String Html_profile = rs.getString("Html_profile");
String Avatar_URL = rs.getString("Avatar_URL");
PersoaneJSON persoana = new PersoaneJSON(id, login_name, email, public_gits, Html_profile, Avatar_URL);
persoane.add(persoana);
}
Gson gson = new Gson();
String json = gson.toJson(persoane);
}
These is what i tried in javascript.
var employeeApp = angular.module("EmployeeApp",[]);
employeeApp.controller("empCtrl",function($scope){
$scope.query = {}
$scope.queryBy = '$'
$scope.employees = [];
$scope.orderProp="name";
});