admin管理员组文章数量:1331450
I have done some Angular 2 for the first time and after the html and css I now am stuck at the DB connection.
Here is what I am working with:
- appponent.ts (Loads the templateURL)
- overviewponent.html (Is the template, 90% html 10% Modal)
- db_basic.db (The DB File)
- sql.js (This can get Values of the db if you do
node sql.js
)
Here the sql.js file to show how I can connect to the DB.
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('../db/db_basic.db');
var check;
db.serialize(function() {
db.each("SELECT * FROM server", function(err, row) {
console.log(row.name);
});
});
db.close();
Now, my Question would be, how do I connect to the DB and use those values in the HTML?
Extra:
I have done some Angular 2 for the first time and after the html and css I now am stuck at the DB connection.
Here is what I am working with:
- app.ponent.ts (Loads the templateURL)
- overview.ponent.html (Is the template, 90% html 10% Modal)
- db_basic.db (The DB File)
- sql.js (This can get Values of the db if you do
node sql.js
)
Here the sql.js file to show how I can connect to the DB.
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('../db/db_basic.db');
var check;
db.serialize(function() {
db.each("SELECT * FROM server", function(err, row) {
console.log(row.name);
});
});
db.close();
Now, my Question would be, how do I connect to the DB and use those values in the HTML?
Extra:
1 Answer
Reset to default 6You need to make a rest API.
The rest API seperates frontend (angular) from backend (database), it serves you data and it can take care of security.
You can use a framework such as express.js to make a rest API in node.
Express.js can also be used to serve your static files (angular project) (so you do not need appache or nginx).
本文标签: javascriptAngular 2 and SQLite connectionStack Overflow
版权声明:本文标题:javascript - Angular 2 and SQLite connection - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742238202a2438462.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论