PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

angular开发中遇到的问题

零下一度
零下一度 原创
2017-07-02 09:36:28 813浏览

一、在我们的angular开发中,会请求数据但轮播图等...在请求过数据后他的事件和方法将不再执行;

看我们的解决方案一:

app.controller("text",function($scope,$http,$timeout){
				$http.get("http://127.0.0.1:3333/huoqu").success(function(data){
					$scope.shuju=data.img
					$timeout(function(){ //在请求完成时,强制更新数据,强制重新运行一次,重新获取数据
						new Swiper(".swiper-container",{
							autoplay:2000,
							autoplayDisableOnInteraction:false,
							loop:true,
							pagination:".swiper-pagination"
						})
					})
				});
						
			});

  解决方案二:(这个虽然可以,但是还是有点小问题)

new Swiper(".swiper-container",{
		autoplay:2000,
		autoplayDisableOnInteraction:false,
		loop:true,
		pagination:".swiper-pagination",
          observer:true,         //子元素改变时自动初始化swiper
          observerParents:true,   //修改swiper时自动初始化swiper
	})//这是插件中俩方法,当子元素或父元素发生改变时 初始化这个swiper,当然这个只是swiper有相信别的也差不多有自己找找。		

  

二、angular在路由开发单页面应用的过程中;你每个页面都会有事件要触发;但你写的切换后就挂掉了。

解决方案:

    

$scope.slide=function(){

    new Swiper("#slide-rl",{
      autoplay:2000,
      autoplayDisableOnInteraction:false,
      pagination:".swiper-pagination",
      loop:true
    })

}

//把我们的代码都写在angular定义的一个方法中,在要引入的html页面调用就ok了

  

以上就是angular开发中遇到的问题的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。