How do I pass a variable to child page in ionicframework ?
Surya
10:05
best way to pass data in ionic
,
cross platform mobile development
,
How do I pass a variable to child page in ionicframework ?
,
ionic framework
,
ionicframework
,
passing data from one page to another
No comments
Problem - > Once I've faced this problem, I've menu created with a list and ng-repeat.
I want to use a variable from an array of objects to create a child menu on another page (like in the Tabs starter Chat tab) but was using ui-sref and I won't work out at the I got solution is that -
Ans->
1- first go to app.js file and define this line params: { varTest: null } varTest is variable which takes your data object and deliver you on the next page .
.state('app.childPageName', {
url: '/test/childPageName',
params: { varTest: null },
views: {
'menuContent': {
templateUrl: 'test/childPageName.html',
controller: 'childPageNameCtrl'
}
}
})
within ng-repeat sectioin ( or within ng-repeat DIV)
use this ui-sref="app.PageNameYouWnatToSendObj ({varTest:ngRepeatObj})"
now go to the controller where you have sent the object ( PageNameYouWnatToSendObj ) and receive the object like this --- >>
$scope.var = $stateParams.varTest;
console.log($scope.var);
• don't forget to inject $stateParams as a dependancy.
• varTest is the name of variable which will carry your object from one page to another page.
•console.log will print the complete object which you have sent form last page.
feel free comment below if you have any question regarding that.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment