How to pass variables in node js?

EasyFree

New Member
#1
Here I'm passing id which stored in m, please help me how to pass id. and call that page using that id. I'm using the embedded JavaScript template as a view engine please help.
Mã:
   $.each(products, function(index, product ) {

            var m= product['_id'];
            //document.write(alert(m));
            string += '<tr><td>'+(index+1)+'</td><td>'+product['_id']+'</td><td>'+product['name']+'</td><td>'+product['category']+'</td><td>'+product['price']+'</td><td>'+product['manufacturer']+'</td><td><a href="/profile/dashboard/update/{{m}}">Update</a> </td></tr>';
        });
route code
Mã:
 app.get('/profile/dashboard/update/:m',function (req,res,next) {
       console.log("hi"+req.params.m);
      });
 

Admin

Administrator
Thành viên BQT
#2
string += '<tr><td>'+(index+1)+'</td><td>'+product['_id']+'</td><td>'+product['name']+'</td><td>'+product['category']+'</td><td>'+product['price']+'</td><td>'+product['manufacturer']+'</td><td><a href="profile/dashboard/update/'+id+'">Update</a> </td></tr>';

It will work
 

Từ khóa phổ biến

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top