On initial load controller doesn't bind properly


#1

Hey guys,
I am running into a very weird issue. When my app loads, I set my default view to go to “login”. If I do this, none of my controller actions do anything. I click on the links, but nothing happens.
However, if I load the “login” page, then go to another page then come back to “login” then everything works just fine. This is not unique to my login page, but seems to happen on all my pages. Basically: Load page 1 ($scope function don’t do anything, go to page 2, go back to page 1, $scope functions are firing properly).
I would post a code pen, but this is only happening on my iPhone and works just fine on the web.


#2

Could you still do a codepen? I can always load it on an iphone and see what the issue is.


#3

@mhartington here is a code pen I put together:
codepen

Currently on the browser, you can {{page_title}} bind perfectly, and it displays: Login.
However on my iPhone all I see is {{PAGE_TITLE}}

Really weird. I have a feeling it’s something else causing the issue, I just can’t pinpoint it yet.
Thanks in advance


#4

ok so I figured out the part of my code that messes everything up (It’s not in the codepen so don’t bother putting it on an iPhone).
When I try to access $cordovaStatusbar (I do $cordovaStatusbar.hide() to get a full page effect), that is when everything breaks.
I think it might be because, on initial load, that object is not accessible to me. Is that possible?
I am also having another very strange issue.
In my main page, when the app is first loaded, I check to see if the user is authenticated and if not, redirect them to the login page.
Now when I try to do $state.go(‘login’) I have this error message popup:

TypeError: ‘undefined’ is not an object (evaluation’data.active[className]’)

The error is happening in: ionic.bundle.js on line 31631. I am the latest version 1.0.10

I think I may have narrowed down the issue. This happens strictly, when I try to do a $state.go as soon as the app is initialized. This causes something in the angular-animate.js file to crash (the line I am referring to). No idea, why or what to do about it though :s

FIXED
wow so before I went completely bonkers I figured out the issue.
In my CSS file I had these lines:

.sample-show-hide {
    -webkit-transition: all ease-in 0.2s;
    transition: all ease-in 0.2s;
}

.sample-show-hide.ng-hide {
    opacity: 0;
}

and this was applied in my initial view before doing $state.go(‘login’); . This was what caused the error. Absolutely no idea why, but I commented it out and it fixed the error