Home > Web Front-end > JS Tutorial > body text

Problems encountered in angular development

零下一度
Release: 2017-07-02 09:36:28
Original
1105 people have browsed it

1. In our angular development, data will be requested but carousel images, etc... After requesting data, its events and methods will no longer be executed;

See our solution 1 :

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"
						})
					})
				});
						
			});
Copy after login

Solution 2: (Although this is possible, it still has a small problem)

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

 

2. In the process of developing a single-page application with Angular routing, each page will have events to be triggered; but the one you write will die after switching.

Solution:

  

$scope.slide=function(){
Copy after login

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

<em>}<br/><br/>//把我们的代码都写在angular定义的一个方法中,在要引入的html页面调用就ok了</em>
Copy after login

 

The above is the detailed content of Problems encountered in angular development. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template