I’m using ngAnimate to animate ng-repeat element (with a filter). On the first load, if I filter the elements, they’re animated. But if I switch to another view and come back, it doesn’t animate anymore.
Also I’m using a search field in the header, if I switch from home (where the search field is) to another page (B), it doesn’t show the back button, but if I switch back to home, then to B. I finally got the back button.
The css:
.list__link.ng-enter,
.list__link.ng-leave {
transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
}
.list__link.ng-enter.ng-enter-active,
.list__link.ng-leave {
opacity: 1;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
height: 52px;
}
.list__link.ng-leave.ng-leave-active,
.list__link.ng-enter {
opacity: 0;
-webkit-transform: translate3d(-50px, 0, 0);
transform: translate3d(-50px, 0, 0);
height: 0;
}
template:
<ion-nav-bar class="item-input-inset bar-stable"
animation="nav-title-slide-ios7"
back-button-type="button-icon"
back-button-icon="icon-arrow-left-c">
<label class="item-input-wrapper">
<i class="icon ion-ios7-search placeholder-icon"></i>
<input type="search" placeholder="Search" ng-model="$parent.search">
</label>
</ion-nav-bar>
<ion-view title="Listes">
<ion-content class="has-header">
<ion-list>
<ion-item ng-show="!listes.lists.length" ui-sref="list/create/">
Aucune liste à afficher. Créer une liste ?
</ion-item>
<ion-item ng-repeat="list in listes.lists | filter:search" class="list__link" type="item-text-wrap" ui-sref="list({ listId: list.id })" ng-show="listes.lists.length">
{{list.name}}
</ion-item>
<ion-item type="item-text-wrap" ui-sref="list/create" ng-show="listes.lists.length" class="positive">
Créer une liste.
</ion-item>
</ion-list>
</ion-content>
</ion-view>
The router:
(function(){
angular.module('lists', [
'lists.services',
'lists.controllers',
'lists.directives'
]);
angular
.module('lists')
.config(config);
function config($stateProvider, $urlRouterProvider) {
// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider
.state('lists', {
url: '/lists/all',
templateUrl: 'modules/lists/templates/lists.html',
controller: 'ListsCtrl as listes'
})
.state('list/create', {
url: '/list/create',
templateUrl: 'modules/lists/templates/list.create.html',
controller: 'ListCreateCtrl as liste'
})
.state('lists/edit/:listId', {
url: '/lists/edit',
templateUrl: 'modules/lists/templates/lists.html',
controller: 'ListsCtrl as liste'
})
.state('list', {
url: '/list/:listId',
templateUrl: 'modules/lists/templates/list.html',
controller: 'ListCtrl as liste',
resolve: {
list: function($stateParams, Lists) {
return Lists.get($stateParams.listId);
}
}
})
};
How can I set back button to be there everytime ? And ngAnimate to work after switching views ?
Thanks!