<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
.box{ width:200px; height:200px; background:red; transition:1s all;}
.box.ng-hide-remove{ opacity:0;}
.box.ng-hide-remove-active{ opacity:1;}
.box.ng-hide-add{ opacity:1;}
.box.ng-hide-add-active{ opacity:0;} </style>
<script src="http://cdn.bootcss.com/angular.js/1.3.8/angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.3.8/angular-animate.min.js"></script>
<script> var m1 = angular.module('myApp',['ngAnimate']);
m1.controller('Aaa',['$scope',function($scope){ $scope.bBtn = true; }]); </script>
</head> <body>
<div ng-controller="Aaa">
<input type="checkbox" ng-model="bBtn">
<div ng-show="bBtn" class="box"></div>
</div>
</body>
</html>
<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
.box{ width:200px; height:200px; background:red;}
</style>
<script src="jquery-1.11.1.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.3.8/angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.3.8/angular-animate.min.js"></script>
<script> var m1 = angular.module('myApp',['ngAnimate']); m1.animation('.box',function(){
return {
addClass : function(element,sClass,done){
//console.log(element);
//console.log(sClass);
//console.log(done);
$(element).animate({width:0,height:0},1000,done);
},
removeClass : function(element,sClass,done){
$(element).css({width:0,height:0});
$(element).animate({width:200,height:200},1000,done);
}
};
}); m1.controller('Aaa',['$scope',function($scope){ $scope.bBtn = true; }]); </script>
</head> <body>
<div ng-controller="Aaa">
<input type="checkbox" ng-model="bBtn">
<!--<div ng-if="bBtn" class="box"></div>-->
<div ng-show="bBtn" class="box"></div>
</div>
</body>
</html>
<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
.box{ width:200px; height:200px; background:red;}
</style>
<script src="jquery-1.11.1.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.3.8/angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.3.8/angular-animate.min.js"></script>
<script> var m1 = angular.module('myApp',['ngAnimate']); m1.animation('.box',function(){
return {
leave : function(element,done){
//console.log(element);
//console.log(sClass);
//console.log(done);
$(element).animate({width:0,height:0},1000,done);
},
enter : function(element,done){
$(element).css({width:0,height:0});
$(element).animate({width:200,height:200},1000,done);
}
};
}); m1.controller('Aaa',['$scope',function($scope){ $scope.bBtn = true; }]); </script>
</head> <body>
<div ng-controller="Aaa">
<input type="checkbox" ng-model="bBtn">
<!--<div ng-if="bBtn" class="box"></div>-->
<div ng-if="bBtn" class="box"></div>
</div>
</body>
</html>

Angular 学习笔记——ng-animate的更多相关文章

  1. angular学习笔记(三十)-指令(7)-compile和link(2)

    继续上一篇:angular学习笔记(三十)-指令(7)-compile和link(1) 上一篇讲了compile函数的基本概念,接下来详细讲解compile和link的执行顺序. 看一段三个指令嵌套的 ...

  2. angular学习笔记(三十)-指令(6)-transclude()方法(又称linker()方法)-模拟ng-repeat指令

    在angular学习笔记(三十)-指令(4)-transclude文章的末尾提到了,如果在指令中需要反复使用被嵌套的那一坨,需要使用transclude()方法. 在angular学习笔记(三十)-指 ...

  3. angular学习笔记(三十)-指令(1)-概述

    之前在 angular学习笔记(十九)-指令修改dom 里面已经简单的提到了angular中的指令,现在来详细的介绍 '指令' 一.指令的创建: dirAppModule.directive('dir ...

  4. angular学习笔记(三十一)-$location(2)

    之前已经介绍了$location服务的基本用法:angular学习笔记(三十一)-$location(1). 这篇是上一篇的进阶,介绍$location的配置,兼容各版本浏览器,等. *注意,这里介绍 ...

  5. angular学习笔记(三十一)-$location(1)

    本篇介绍angular中的$location服务的基本用法,下一篇介绍它的复杂的用法. $location服务的主要作用是用于获取当前url以及改变当前的url,并且存入历史记录. 一. 获取url的 ...

  6. angular学习笔记(三十)-指令(10)-require和controller

    本篇介绍指令的最后两个属性,require和controller 当一个指令需要和父元素指令进行通信的时候,它们就会用到这两个属性,什么意思还是要看栗子: html: <outer‐direct ...

  7. angular学习笔记(三十)-指令(7)-compile和link(1)

    这篇主要讲解指令中的compile,以及它和link的微妙的关系. link函数在之前已经讲过了,而compile函数,它和link函数是不能共存的,如果定义了compile属性又定义link属性,那 ...

  8. angular学习笔记(三十)-指令(5)-link

    这篇主要介绍angular指令中的link属性: link:function(scope,iEle,iAttrs,ctrl,linker){ .... } link属性值为一个函数,这个函数有五个参数 ...

  9. angular学习笔记(三十)-指令(2)-restrice,replace,template

    本篇主要讲解指令中的 restrict属性, replace属性, template属性 这三个属性 一. restrict: 字符串.定义指令在视图中的使用方式,一共有四种使用方式: 1. 元素: ...

  10. Angular 学习笔记 ( CDK - Accessibility )

    @angular/ckd 是 ng 对于 ui 组建的基础架构. 是由 material 团队开发与维护的, 之所以会有 cdk 看样子是因为在开发 material 的时候随便抽象一个层次出来给大家 ...

随机推荐

  1. hihocoder 后缀自动机二·重复旋律5

    求不同子串个数 裸的后缀自动机 #include<cstring> #include<cmath> #include<iostream> #include<a ...

  2. 经典 Javascript 正则表达式

    正则表达式用于字符串处理,表单验证等场合,实用高效,但用到时总是不太把握,以致往往要上网查一番.我将一些常用的表达式收藏在这里,作备忘之用.匹配中文字符的正则表达式:  }

  3. gluPerspective(解释得很好)

    http://www.cppblog.com/COOOOOOOOL/archive/2009/12/28/104255.html 函数原型gluPerspective(GLdouble fovy,GL ...

  4. 28.Implement strStr()---kmp

    题目链接:https://leetcode.com/problems/implement-strstr/description/ 题目大意:字符串匹配,从字符串中,找到给定字符串第一次出现的位置下标, ...

  5. Android 利用Sharp样式设置文本框EditText圆角形状

    1.首先新建样式文件editsharp.xml: <?xml version="1.0" encoding="utf-8"?> <shape ...

  6. Mysql优化的方法

    一.表的优化: 1: 定长与变长分离 如 time.手机号等,每一单元值占的字节是固定的. 核心且常用字段,宜建成定长,放在一张表,查询速度会很快 而varchar, text,blob,这种变长字段 ...

  7. PHP中利用PHPMailer使用QQ邮箱实现邮件发送

    /** * 下订单发送邮件 * @to 收件人 @title 标题 @content 内容 */ function sendMail($to,$title,$content){ //引入PHPMail ...

  8. Java屌炸天学习路线图

            第一阶段:Java基础篇 编号 课程 课程目录 打包下载地址 讲师 01 J2SE(40课时) http://www.java1234.com/zy001.html http://pa ...

  9. VS2015自动添加注释

    记录下创建一个MVC5下的Models文件夹下的代码添加自动注释修改文件路径位置: 让VS自动生成类的头部注释,只需修改两个文集即可,一下两个路径下个有一个 Class.cs文件 C:\Program ...

  10. 利用Log4net组件记录日志

    项目中利用Log4net记录日志还是比较方便的,我也按照网上的一些操作进行了实践 参考文章 1:Log4Net使用指南2:LOG4NET日志配置 组件下载 log4net组件下载 1:设置配置文件,这 ...