how to join two table in codeigniter easily[updated] | ci_model | ci_controller | codeigniter 3 -datainflow
Hello, friend today i will show you, how to render a HTML view in Node JS.
Node JS express view file extension is ejs or jade. There are a routes folder in node js and all view pages are rendered from there. So, in the routes js file, we have to use the following code
res.render('about',{about_data: results, title: 'About Us',update_record:updRec});
here “res” is response, which is rendered to about page and in the second braces the variable name and its data is assigned there to pass that in maintained view page.
the full code in the routes file is given below
var express = require('express'); var router = express.Router(); var assert = require('assert'); router.get('/about', function(req, res, next){ var resultArray = []; var updRec = [{ id: 0, title: '', description: '' } ]; res.render('about',{about_data: updRec, title: 'About Us'}); }); module.exports = router;
The view page content is following
<html>
<head><title><%= title %></title></head>
<body>
<%= JSON.stringify(about_data); %>
</body>
</html>
In this HTML page passed data from routes printed here.
Related posts