Pass object as parameter to onclick method in handlebars template

前端 未结 1 1688
既然无缘
既然无缘 2021-02-10 03:43

I have a JSON that looks like this:

{
list: [
        { name: \'AAA\',
          id: 1,
          age: 34
        },
        { name: \'BBB\',
          id: 2,
           


        
1条回答
  •  无人及你
    2021-02-10 04:16

    Posting for future references:

    Got my answer from here:

    Handlebars.js parse object instead of [Object object]

    Turns out Handlebar does a toString on the data before pasting into the template. All I had to do was to register a helper method that converts it back to json.

    Handlebars.registerHelper('json', function(context) {
        return JSON.stringify(context);
    });
    
    
  • {{name}} ({{age}})
  • 0 讨论(0)
提交回复
热议问题