I tried my best
var myapp = angular.module('myApp', ["ui.router", "ngAnimate", 'hmTouchEvents', 'ngSanitize']) myapp.config(function($stateProvider, $urlRouterProvider, $animateProvider){ $animateProvider.classNameFilter(/ani-/); $stateProvider .state('anon',{ template:'<ui-view class="ani-ui-view" ng-class="abstractView"/>', abstract:true }) .state("anon.foo", { url: "/foo", templateUrl : '/views/statechange/resources/partials/foo.html', controller : 'fooCtl' }) .state("anon.bar", { url: "/bar", templateUrl : '/views/statechange/resources/partials/bar.html', controller : 'barCtl' }); $urlRouterProvider.otherwise("/foo"); }) .run(function($rootScope){ $rootScope.$on("$stateChangeStart", function(event, currRoute, prevRoute, rejection) { }); }) .animation('.fade-in', function($timeout){ return { enter : function(element, done){ element.css({ 'opacity':0, transition:'all 300ms' }); $timeout(function(){ element.css({ 'opacity':1 }); },0) } } }) .animation('.show-bar', function($timeout) { return { enter : function(element, done) { element.css({ transition:'all 300ms', transform:'translate3d(100%, 0, 0)' }); $timeout(function(){ element.css({ transform:'translate3d(0, 0, 0)' }); },0); }, leave : function(element, done) { element.css({ transition:'all 300ms', transform:'translate3d(0, 0, 0)' }); $timeout(function(){ element.css({ transform:'translate3d(100%, 0, 0)' }); },0); }, // you can also capture these animation events addClass : function(element, className, done) {}, removeClass : function(element, className, done) {} } }) .animation('.slide-foo', function($timeout) { return { enter : function(element, done) { element.css({ transition:'all 300ms', transform:'translate3d(-100%, 0, 0)' }); $timeout(function(){ element.css({ transform:'translate3d(0, 0, 0)' }); },0); }, leave : function(element, done) { element.css({ transition:'all 300ms', transform:'translate3d(0, 0, 0)' }); $timeout(function(){ element.css({ transform:'translate3d(100%, 0, 0)' }); },0); }, // you can also capture these animation events addClass : function(element, className, done) {}, removeClass : function(element, className, done) {} } }) .controller('mainCtl',[ '$scope', '$state', '$rootScope', '$window', function($scope, $state, $rootScope, $window){ $rootScope.abstractView = 'fade-in'; console.log('mainCtl'); } ]) .controller('fooCtl',[ '$scope', '$state', '$timeout', '$rootScope', function($scope, $state, $timeout, $rootScope){ $scope.changeState = function(_state){ $rootScope.abstractView = 'show-bar'; $state.go('anon.bar'); } $scope.tip="I am foo"; } ]) .controller('barCtl',[ '$scope', '$state', '$stateParams', '$timeout', '$rootScope', '$window', function($scope, $state, $stateParams, $timeout, $rootScope, $window){ $timeout(function(){ $scope.barshow = true; }); $scope.tip="I am bar"; $scope.goBack = function($event){ $rootScope.abstractView = 'show-bar'; $window.history.back(); } } ]);
index html
<body ng-controller="mainCtl"> <div class="ui-view-container"> <div ui-view></div> </div> </body>
foo html
<section ng-controller="fooCtl"> <div class="well"> {{tip}} <div class="text-right"> <button class="btn btn-default" hm-tap="changeState('anon.bar')">to bar -></button> </div> </div>
bar html
<section ng-controller="barCtl"> <div class="well"> <div class="text-left"> <button class="btn btn-info" hm-tap="goBack($event);"><- back</button> </div> {{tip}} </div>
some css
.ui-view-container { position:relative; } .ani-ui-view{ position: absolute; left: 0; top: 0; width:100%; }
Hope this helps you.