last day (14 days later) » 

7:23 PM
0
Q: Angular forEach Loop Not Working On Mobile Browsers

JefHere's a controller for a web app I made with AngularJS. I'm using ngStorage to locally store some objects and with this controller I'm looping thru those stored objects and spitting out their names in the console. The code below works fine on desktop browsers, Safari & Chrome. But when I use a...

 
what is the type and structure of $scope.$storage.project?
 
Jef
It's an array. I don't follow what you mean about the structure tho. And it does have objects in it. They show up in the console on desktop browsers.
 
i was just trying to create a reproducible sample. forEach can take either an array or an object. code.angularjs.org/1.2.13/docs/api/angular.forEach
 
Jef
Yes. $scope.$storage.project is an array that I push objects to and I'm able to loop thru the array on desktop versions of browsers. But on the mobile versions, I fire the saveGoal function listed above and nothing happens.
@ps2goat I updated the code to be more complete. I was trying to keep my example as concise as possible. Thanks for taking a look a this btw.
 
what is your mobile device?
 
Jef
7:39 PM
I tested it on mobile Safari and mobile Chrome. My device is an iPhone.
 
ah, it's likely that private mode is on by default. we ran into this issue in one of our sites, as well. when private mode is on in mobile safari, the local and session storage is not available, only cookies.
we made an in-memory object that works like session storage, and we use that instead. I don't think $storage has this work-around.
that wasn't mine, just an option.
 
Jef
I found a similar post about that somewhere else so I confirmed that private browsing is off. I also had a buddy check on his Android -- same deal. It seems to not like the forEach loop for some reason.
No errors in the console whatsoever.
 
7:54 PM
ok
if you try log the $storage project variable above the foreach, does it get logged?
 
Jef
I'm checking right now.
 
Jef
8:16 PM
It logs as an empty array since I haven't succeeded in pushing anything to it. T_T
 
8:51 PM
can you add data during loading to see if it comes back out?
 

last day (14 days later) »