Angularjs 常用方法

1. isArray使用

效果图如下,结果为true

2.uppercase使用

$scope.name = "zhangsan";
$scope.name = angular.uppercase( $scope.name );
htmle中
zhangsan 转为大写 {{name}} 结果为:zhangsan 转为大写 ZHANGSAN 3. toJson方法 将json转为字符串
var  json = {"name":"hello", "age":"20"};
var jsonstr = angular.toJson(json);
console.log(jsonstr); 打印结果
{"name":"hello","age":"20"} 4. formJson方法
将string转为json

var jsonstr = '{"name":"hello", "age":"20"}';
var json = angular.fromJson(jsonstr);
console.log(json);

打印效果

5. forEach使用

var json = {"name":"hello", "age":"20"};
angular.forEach(json,function(val, key){
console.log(key + " : " + val);
});

效果:

加入第三个参数results

var json = {"name":"hello", "age":"20"};
var results=[];
angular.forEach(json,function(val, key){
this.push(key + " : " + val);
}, results);

console.log(results);

显示结果

7. 模块依赖

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="module02.js"></script>
</head>
<body ng-app="myApp">
<div> <div ng-controller="firstController">
{{name}}
</div>
<div ng-controller="secondController">
{{name}}
</div>
<div ng-controller="thirdController">
{{name}}
</div>
</div>
<script type="text/javascript">
var app = angular.module("myApp", ['myApp2']);
app.controller('firstController',['$scope',function($scope){
$scope.name = "张三";
}]);
</script> </body>
</html>

  

module02.js文件
var app2 = angular.module("myApp2", []);
app2.controller('secondController',function($scope){
$scope.name='李四';
}); app2.controller('thirdController',function($scope){
$scope.name='王五';
});

  显示效果

8. Jquery的使用
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="jquery-1.11.1.js"></script>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="module02.js"></script>
</head>
<body ng-app="myApp">
<div> <div ng-controller="firstController">
<div id="main"></div>
{{name}}
</div>
<div ng-controller="secondController">
{{name}}
</div>
<div ng-controller="thirdController">
{{name}}
</div>
</div>
<script type="text/javascript">
var app = angular.module("myApp", ['myApp2']);
app.controller('firstController',['$scope',function($scope){
$scope.name = "张三";
$('#main').html('<span>hello world</span>');
}]);
</script> </body>
</html>

  显示结果

9 angular.element的使用

 var main = document.getElementById('main');
angular.element(main).html("hello man");

  


参考 https://www.angular.cn
												

Anglarjs 工具方法的更多相关文章

  1. JQuery操作类数组的工具方法

    JQuery学习之操作类数组的工具方法 在很多时候,JQuery的$()函数都返回一个类似数据的JQuery对象,例如$('div')将返回div里面的所有div元素包装的JQuery对象.在这中情况 ...

  2. jQuery工具方法

    目录 常用工具方法 判断数据类型的方法 Ajax操作 $.ajax 简便写法 Ajax事件 返回值 JSONP 文件上传 参考链接 jQuery函数库提供了一个jQuery对象(简写为$),这个对象本 ...

  3. jQuery晦涩的底层工具方法们

    这里整理的是jQuery源码中一些比较晦涩难懂的.内部的.最底层的工具方法,它们多为jQuery的上层api方法服务,目前包括: jQuery.access jQuery.access: functi ...

  4. angular的工具方法笔记(equals, HashKey)

    分别是angular脏值检测的工具方法equals和 类HashKey的使用方法 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transi ...

  5. zepto源码学习-02 工具方法-详细解读

    上一篇:地址 先解决上次留下的疑问,开始看到zepto.z[0]这个东西的时候,我很是不爽,看着它都不顺眼,怎么一个zepto的实例对象var test1=$('#items');  test__pr ...

  6. jQuery源代码 解析一 工具方法

    1. 外层沙箱以及命名空间$ 几乎稍微有点经验前端人员都这么做,为了避免声明了一些全局变量而污染,把代码放在一个"沙箱执行",然后在暴露出命名空间(可以为API,函数,对象): 2 ...

  7. Underscore.js 常用类型判断以及一些有用的工具方法

    1. 常用类型判断以及一些有用的工具方法 underscore.js 中一些 JavaScript 常用类型检查方法,以及一些工具类的判断方法. 首先我们先来谈一谈数组类型的判断.先贴出我自己封装好的 ...

  8. 秒味课堂Angular js笔记------Angular js中的工具方法

    Angular js中的工具方法 angular.isArray angular.isDate angular.isDefined angular.isUndefined angular.isFunc ...

  9. javascript 的工具方法 --- 类型判断

    Javascript中常见类型对象有: Boolean, Number, String, Function, Array, Date, RegExp, Object, Error, Symbol等等. ...

随机推荐

  1. JavaScript运算符:递增递减运算符前置和后置的区别

    从两段代码说起 var num1 = 2; var num2 = 20; var num3 = --num1 + num2; var num4 = num1 + num2; console.log(n ...

  2. shiro学习笔记-Subject#login(token)实现过程

    本博文所有的代码均为shiro官网(http://shiro.apache.org/)中shiro 1.3.2版本中的源码. 追踪Subject的login(AuthenticationToken t ...

  3. PHP:第四章——PHP数组处理函数

    <pre> <?php //数组处理函数 header("Content-Type:text/html;charset=utf-8"); //compact(); ...

  4. zoj3732&& hdu4797 Graph Reconstruction

    Graph Reconstruction Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Let there ...

  5. bzoj3601

    题解:gi(pq=pqi-pqi+di 至于为什么,可以看看往上的题解 代码: #include<bits/stdc++.h> using namespace std; typedef l ...

  6. Delphi中的文件扩展名

    Filename Extensions in Delphi http://delphi.about.com/od/beginners/a/aa032800a.htm Try building a sm ...

  7. Active MQ的初步探索

    参考链接: http://blog.csdn.net/jiuqiyuliang/article/details/46701559 JMS是jee规范,active MQ是该规范的实现 Active M ...

  8. hibernate级联 cascade属性(转)

    在Hibernate中,针对持久化实体的配置文件中有Cascade这样一个属性,顾名思义就是级联,也就是说在操作当 前实体时,针对当前实体的操作会影响到相应配置的关联实体.比如针对当前实体进行保存操作 ...

  9. Goolge全球各国域名大全

    搜索过技术文章的朋友都知道,Google的搜索功力绝对是世界第一,仅仅搜索中文还体现不出Google的功力,如果大家是做外贸或者搜索其它语言的文章,就会知道Google的内涵有多少了.全世界的国家Go ...

  10. SharePoint Infopath表单服务-PowerShell

    1. 激活可浏览的表单模板 Set-SPInfoPathFormsService -AllowUserFormBrowserEnabling $true -AllowUserFormBrowserRe ...