Setting toggle option when app starts

I’m using localStorage to save options on a Settings page in a tab view. It works, but because I’m setting the saved toggle settings in $ionicPlatform.ready(function(){} in my SettingsCtrl the toggle starts out off and then animates to on right as the tab loads.

Is there any way to set it to be on when the app itself is initiated rather than the tab?

You should move the code to a factory, which will become available when the app starts.

Hey! Thanks for the help. I took a look into factories and I’m still very new to Angular, so I’m unsure how to do it. I have two separate controllers right now, SettingsCtrl and DashCtrl. Both use $ to fill the radio lists and set/retrieve the value.

I tried copying the code directly from the controllers into a factory service, but it wouldn’t generate the ng-repeat radio elements. How would you go about converting what I have currently to a factory? Example plnkr here.

Take a look at the example from the tabs starter project.

Whats being set up in a factory is just the data. Then you return that data in a controller. What you have right now is a bit more logic than you need for your use case