javascript - $state.go not working to go back for the first view with ionic -
hey have problem, can move normaly 1 view another, when 1 , want go first view of project don't go.
my app.js
app.config(function($stateprovider, $urlrouterprovider) { // setup abstract state tabs directive $stateprovider .state('game', { url: "/game", abstract: true, templateurl: "templates/game.html" }) .state('game.begin', { url: '/begin', views: { 'begin': { templateurl: 'templates/begin.html', controller: 'beginctrl' } } }) .state('game.match', { url: '/match/:filewithquestions', views: { 'match': { templateurl: 'templates/match.html', controller: 'matchctrl' } } }) .state('game.result', { url: '/result', views: { 'result': { templateurl: 'templates/result.html', controller: 'resultctrl' } } }); $urlrouterprovider.otherwise('/game/begin'); })
the place call page problem is.
function countdown() { mytymeout = $timeout(countdown, 1000); $scope.counter--; if($scope.counter === 0) { $timeout.cancel(mytymeout); sendarray.senddata(answeredwords); releasemidias(); $state.go('^.result'); } navigator.accelerometer.getcurrentacceleration(onsuccess, onerror); }
the controller problem is:
controller.controller('resultctrl', function($scope, $state, $timeout, sendarray) { screen.lockorientation('portrait'); $scope.array = sendarray.getdata(); $scope.back = function() { $state.go('^.begin'); } });
the html funciton called
<ion-nav-view name="result"> <ion-view title="result"> <ion-pane> <div class="back_div"> <a ng-click="back()"> <img src="img/result/voltar.png" /> </a> </div> <div ng-repeat="item in array"> <h1 ng-if="item.answer == true">{{item.word}}</h1> <h1 ng-if="item.answer == false" style="color: red;">{{item.word}}</h1> </div> </ion-pane> </ion-view>
the function called i've tried alerts, , state.go gives me object, doesn't redirect page...
i found out somewhere have disable $ionichistory
before going home.
.controller('somectrl', function($scope, $state ,$ionichistory) { $scope.backfunction = function() { $ionichistory.nextviewoptions({ disableback: true }); $state.go('^.home'); }; });
hope helps.
Comments
Post a Comment