javascript - how to pass more than one value in pushpage method of onsen ui -


hello newbie in angulajs , javasript , making demo of passing values in pushpage function of onsen ui. have succeeded in passing 1 value in push page while trying pass 2 values not passing, can please me resolve issue, have tried below:

(inside controller)

var content = ' ';             var resid = ' ';             var catname = ' '            var options,           elem,          obj = {};                 (i = 0 ; i< data ['details'].length ; i++)             {                 resid=  + data['details'][i]['intglcode'] ;                  catname   = data['details'][i]['varname'];        obj['params'] = resid; obj['params1'] =  catname; options = json.stringify(obj); console.log(options); elem = "<li class='list__item list__item--chevron' onclick=gallery.pushpage('list-page.html', "+options+");>";  console.log(elem);                 if (content === ' ')                 {                     //{params:'+resid+',params1 : '+catname+'}                      content =elem+ //    '<li class="list__item list__item--chevron" onclick=gallery.pushpage("list-page.html", { params: '+resid+' });>'+   '<ons-icon class="ons-icon ons-icon--ion ion-android-restaurant fa-lg" fixed-width="true" icon='+data['details'][i]['varicon']+'>'+'</ons-icon>' 

you need create pushpage() parameter object first using bracket notation allows inject attributes values. o once object created can parse string concatenate string in controller. following demonstrated this

var options,      elem,     obj = {},          resid = 'foo',     catname = 'bar'; obj['params'] = resid; obj['params1'] =  catname; options = json.stringify(obj); console.log(options); elem = "<li class='list__item list__item--chevron' onclick=gallery.pushpage('list-page.html', "+options+");>"; console.log(elem); /* prints <li class='list__item list__item--chevron' onclick=gallery.pushpage('list-page.html', {"params":"foo","params1":"bar"});> */ 

check demo below.

var options,       elem,      obj = {},           resid = 'foo',      catname = 'bar';  obj['params'] = resid;  obj['params1'] =  catname;  options = json.stringify(obj);  console.log(options);  elem = "<li class='list__item list__item--chevron' onclick=gallery.pushpage('list-page.html', "+options+");>";    pre.innerhtml = elem;
<pre id="pre"></pre>


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -