javascript - ejs code to display a string variable sent by PostController.js in Sails -
attempting display string variable in postview.ejs sent postcontroller.js in sails
val string variable
[ ejs html javascript sails express node.js ]
postcontroller.js
module.exports = { post : function (req, res) { var val = req.param('valeur'); console.log('val =', valeur); // controller test : no problem far res.render('postview')
postview.ejs (?)
<html> <h1>post view</h1> <body> // until running smoothly <script type=«text/javascript»> document.write ('your value :' + val) </script> </body> </html>
ejs code not working : javascript relevant here ?
what correct code in sails display val string in return view ?
you first need pass data want view.
res.render('postview', {val: val})
then using ejs templates, use following code render value <%= val %>
Comments
Post a Comment