angular学习笔记
1、forEach
arr:参数是key,index
json:与jquery相反,参数是value,key
2、str-->json
JSON.parse() angular.fromJson()
json-->str
JSON.stringify() angular.toJson() 后面跟一个true,会转换成json形式的字符串,方便查看
3、copy(),extend(),merge()的区别
angular.copy(source, [destination]);
1、如果destination省略,则创建出一个对象或数组
2、如果destination存在,删除destination里的所有属性,把source里的所有属性深copy过来
3、如果source不是对象或数据(如:null或undefined),直接return source
4、如果source和destination一样,则抛出异常
angular.extend(dst, src);
和jquery中的$.extend(dst,src)一样
angular.merge(dst,src);
和jquery中的$.extend(true,dst,src)一样
注:copy和(extend|merge)中的参数是相反的。
4、angular.identity(value) 直接返回传入的值,即value
function transformer(transformationFn, value) {
return (transformationFn || angular.identity)(value);
};
//相当于如下
if (transformationFn){
return transformationFn(value)
} else {
return value
}
5、angular.noop(),什么都不操作
function foo(callback) {
var result = calculateResult();
(callback || angular.noop)(result);
}
//有callbak,则执行callback函数,没有则什么都不操作
6、$filter('orderBy')(array,expression,reverse)
第三个参数,排序是正序还是反序,不写或者false为正序,true为反序
7、ng-repeat
$index :从0开始
$even:第一个偶数为true
8、$filter('filter')(array,expression,comparator)
array:souce
expression:
1、string: 字符串或者对象字符串属性
前面加上“!”会取反向
2、object:{name:'M',phone:'1'},会找name为M并且phone为1,只能找同级的
{$:'text},会找任意属性为text,可以找到嵌套的
{name:'!M'},会找name不为M的
3、function(value,index,array){}:
value为每一个值
index为索引
array为整个大的数组
return true为找到
comparator:
1、function(actual,expected){}:
true为找到,actual为每次进来的值,有可能是string或者object,expected为希望找到的值(即:第二个参数中的expression)
2、true
严格,即return angular.equals(actual,expected),全等(区别大小写)
3、false|undefined
模糊,不区分大小写
angular学习笔记的更多相关文章
- angular学习笔记(三十一)-$location(2)
之前已经介绍了$location服务的基本用法:angular学习笔记(三十一)-$location(1). 这篇是上一篇的进阶,介绍$location的配置,兼容各版本浏览器,等. *注意,这里介绍 ...
- angular学习笔记(三十一)-$location(1)
本篇介绍angular中的$location服务的基本用法,下一篇介绍它的复杂的用法. $location服务的主要作用是用于获取当前url以及改变当前的url,并且存入历史记录. 一. 获取url的 ...
- angular学习笔记(三十)-指令(10)-require和controller
本篇介绍指令的最后两个属性,require和controller 当一个指令需要和父元素指令进行通信的时候,它们就会用到这两个属性,什么意思还是要看栗子: html: <outer‐direct ...
- angular学习笔记(三十)-指令(7)-compile和link(2)
继续上一篇:angular学习笔记(三十)-指令(7)-compile和link(1) 上一篇讲了compile函数的基本概念,接下来详细讲解compile和link的执行顺序. 看一段三个指令嵌套的 ...
- angular学习笔记(三十)-指令(7)-compile和link(1)
这篇主要讲解指令中的compile,以及它和link的微妙的关系. link函数在之前已经讲过了,而compile函数,它和link函数是不能共存的,如果定义了compile属性又定义link属性,那 ...
- angular学习笔记(三十)-指令(6)-transclude()方法(又称linker()方法)-模拟ng-repeat指令
在angular学习笔记(三十)-指令(4)-transclude文章的末尾提到了,如果在指令中需要反复使用被嵌套的那一坨,需要使用transclude()方法. 在angular学习笔记(三十)-指 ...
- angular学习笔记(三十)-指令(5)-link
这篇主要介绍angular指令中的link属性: link:function(scope,iEle,iAttrs,ctrl,linker){ .... } link属性值为一个函数,这个函数有五个参数 ...
- angular学习笔记(三十)-指令(2)-restrice,replace,template
本篇主要讲解指令中的 restrict属性, replace属性, template属性 这三个属性 一. restrict: 字符串.定义指令在视图中的使用方式,一共有四种使用方式: 1. 元素: ...
- angular学习笔记(三十)-指令(1)-概述
之前在 angular学习笔记(十九)-指令修改dom 里面已经简单的提到了angular中的指令,现在来详细的介绍 '指令' 一.指令的创建: dirAppModule.directive('dir ...
- angular 学习笔记
每天进步一点点,学习笔记 笔记来自 angular权威指南 如果想要屏蔽浏览器对表单的默认验证行为,可以在表单元素上添加 novalidate 标记. 而按钮标签则完全忽略 hr e f 属性,并不 ...
随机推荐
- [转]Metasploit的meterpreter黑客脚本列表
原文地址: 摘要: Metasploit的框架是一个令人难以置信的黑客攻击和渗透测试工具,每一个黑客称职的应该是熟悉和有能力的. 在上一篇文章中,我提供了你的 meterpreter 命令列表.这些命 ...
- Aspose.cells异步读写操作
public class AsyncExcel : Excel { static readonly object _objForlock = new object(); //public List&l ...
- 修改List报ConcurrentModificationException异常原因分析
使用迭代器遍历List的时候修改List报ConcurrentModificationException异常原因分析 在使用Iterator来迭代遍历List的时候如果修改该List对象,则会报jav ...
- Arduino 各种模块篇 motor shield
根据arduino官方网站出的shield, 类似的情况有很多中motor shield 这里测试采用的是http://www.seeedstudio.com/wiki/Motor_Shield_V1 ...
- cooking eggs
1: what is egg? what's the shape of it in details? 2: can egg run like this http://item.taobao.com/i ...
- Html中DIV成为超级链接,解决在360浏览器+IE9显示小手图标的兼容性!
Html中DIV成为超级链接,解决在360浏览器+IE9显示小手图标的兼容性! <div style="cursor:pointer;" onclick="sele ...
- Android 权限管理
从 Android 6.0(API 级别 23)开始,用户开始在应用运行时向其授予权限,而不是在应用安装时授予.此方法可以简化应用安装过程,因为用户在安装或更新应用时不需要授予权限.它还让用户可以对应 ...
- JVM参数设置、分析
不管是YGC还是Full GC,GC过程中都会对导致程序运行中中断,正确的选择不同的GC策略,调整JVM.GC的参数,可以极大的减少由于GC工作,而导致的程序运行中断方面的问题,进而适当的提高Java ...
- 自定义JSP中的Taglib标签之四自定义标签中的Function函数
转自http://www.cnblogs.com/edwardlauxh/archive/2010/05/19/1918589.html 之前例子已经写好了,由于时间关系一直没有发布,这次带来的是关于 ...
- 【JS学习笔记】提取行间事件
行间提取事件第一种方法: function 名字() { ... } oBtn.onclick=名字: 第二种方法: oBtn.onclick=function () { ... } 其实在JS当中, ...