angularjs - $state.go after a timeout or in $ionicPlatform.ready makes a boolean seem truthy and falsy at the same time -
we want have dynamic startup state in our application depending on factors (scroll down if you're interested in context).
we have following code achieve it: have fake routing
state default state no ui makes decisions routing.
mainmodule.config(function($stateprovider, $urlrouterprovider) { // ... $stateprovider.state({ 'routing': { url: '/routing', controller: 'routingcontroller' } }); $urlrouterprovider.otherwise('/routing'); }); mainmodule.controller('routingcontroller', function($state, $ionicplatform, $timeout) { function donormalstartup() { console.log("donormalstartup"); $state.go('timeline'); } donormalstartup(); // fine // $ionicplatform.ready(donormalstartup); // double ng-hide bug! // $timeout(0).then(donormalstartup); // bug });
for simplicity put in example should route timeline
state. when state navigation directly in routingcontroller
, works fine, when in $ionicplatform.ready
callback, produces weird bug:
we have 2 html nodes ng-show
bound same variable, 1 negated. @ times, 1 of them should shown. however, angular adds ng-hide
both nodes!
the bug happens when firing navigation inside $ionicplatform.ready
or after timeout.
it seems angular binding machinery gets broken @ point. ideas how can possibly happen?
context:
if android app started via deep link web - i.e. http link intercepted app, want read original request url , decide routing.
to this, use webintent plugin. can read output when plugin initialized, i.e. inside $ionicplatform.ready
callback.
edit:
i tried changing bound expression showemptytimeline
foo.showemptytimeline
, later showemptytimeline()
method call, inside call console.log
contents , they're boolean false
.
changing callback donormalstartup
function(){donormalstartup()}
doesn't change anything.
try using
$ionicplatform.ready(function() { donormalstartup(); }
instead of code
Comments
Post a Comment