我想每次转到另一个页面时都加载页面,所以我想使用animsition,但它不加载视图当我看到url时,起初它已经更改为localhost/home --> localhost/product,但突然它会再次重新加载并回家。
代码
myApp.directive('animsition', function($location,$timeout){
$(".animsition").animsition({
inClass: 'fade-in',
outClass: 'fade-out',
inDuration: 10,
outDuration: 10,
// linkElement: '.animsition-link',
linkElement: 'a:not([target="_blank"]):not([href^="#"]):not([class*="lg-trigger"]):not([socialshare])',
loading: true,
loadingParentElement: 'body',
loadingClass: 'animsition-loading',
loadingInner: '<img src="images/loading.gif" />', // e.g '<img src="assets/img/loading.svg" />'
timeout: false,
timeoutCountdown: 4000,
onLoadEvent: true,
browser: ['animation-duration', '-webkit-animation-duration', '-o-animation-duration'],
overlay : false,
overlayClass : 'animsition-overlay-slide',
overlayParentElement : 'body',
transition: function(url){
window.location.href = url;
}
});
ui.router
.state('home',{
url:'/home',
params:{opacity:null,headnav_status:null,no_login:null},
templateUrl:'home.html',
controller:'HomeCtrl'
})
.state('product',{
url:'/product',
params:{product_id:null},
templateUrl:'product.html',
controller:'ProductCtrl'
})
点击功能
$scope.gotoProduct = function(product_id) {
$state.go('product', { product_id: product_id});
}
<a ng-click="gotoProduct(id)">Product </a>
有人知道为什么吗?
谢谢