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 I’m using ui-sref and I can’t work out how to do it.
Yes, you can by ‘n’ number of ways but what I prefer is that ->
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 .
• 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.
I used one controller for both the menu and the submenu so when I passed the variable… well, it wasn’t working.
I’ve moved all the submenu creation code to a new controller and it works great now - thanks so much!
This is what I’m doing to greate the objects for the submenu. The passed parameter determines what is in the submenu object that is iterated over by the ng-repeat.
I’m sure you get the idea It’s all very nice and so, so much easier than the old way I was doing it!
Now all I need is a way to creat the actual content from JSON that is pulled from localStorage.
The ultimate goal is have even these menus and submenus from JSON in localStorage. Then I can integrate with Firebase and have a fully updatable app that just polls Firebase for a change and, if it finds one, pulls a whole bunch of JSON that is used to construct the app. I didn’t think I’d ever be able to do this but what you’ve just shown me has made all the pieces fall into place!