(function (module) { module.controller('tabsCtrl', ["$scope","$http", "myService","storage", "$ionicHistory", "$state", function ($scope,$http, myService, storage,$ionicHistory, $state) { $scope.$on('$ionicView.beforeEnter', function () { $scope.user = storage.getObject('user'); }); $scope.go = function(target) { $ionicHistory.clearHistory(); if($state.current.name=="app.home"&&target=="app.add"){ target = "app.home_add" } if($state.current.name=="app.my"&&target=="app.add"){ target = "app.my_add" } $state.go(target); }; $scope.myMes = function(){ $scope.go("app.my") }; $scope.myIndex = function(){ $scope.go("app.home") }; }]); })(angular.module('app.controllers'));