how to pass more than one value to next page in angularjs

允我心安 提交于 2020-01-17 04:28:06

问题


hello i am newbie to angularjs and using onsen ui in my demo aplication,i have 2 pages in my application,In this i want to pass two values to the next page,i succeed to passing one value but when i am sending second onew it gives me exception of ReferenceError: Restaurant is not defined, i have tried concating string but still same thing happened,so can anybuddy please help me to figure it out,my code is: html

<ons-button onclick=gallery.pushPage("list-page.html",{params:'+resid+',params1:'+listtitle+'}); modifier="clean" class="ng-isolate-scope effeckt-button button--clean slide-left"  ng-model="Data.FirstName" ng-module="cattitle"><span class="label ons-button-inner">

js

  var FkCategory = page.options.params;
         var title = page.options.params1;

回答1:


Here you go buddy.. It is really easy to do..

1st page HTML

<div  ng-controller="dataController">
   <button class="button button--large--cta" ng-click="nextPage()"></button>
</div>

passing values - JS

myApp.controller('dataController', function ($scope) {
    var valueSet;
    valueSet.value1 = "value1";
    valueSet.value2 = "value2";
    $scope.nextPage = function () {
        yourNavigator.pushPage('destination.html', { animation: defaultTransition, values: valueSet })
    };
});

retrieving values - JS

var valueSet = yourNavigator.getCurrentPage().options.values;
console.log( valueSet.value1 + "& " + valueSet.value2);


来源:https://stackoverflow.com/questions/33118574/how-to-pass-more-than-one-value-to-next-page-in-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!