angularjs 学习笔记
2016-03-14 18:21
537 查看
文档 https://code.angularjs.org/1.3.8/docs/api/ng/function/angular.bootstrap
function
angular.bootstrap(); //猜测是 绑定 ng-app 这个指令的,
angular.bootstrap(element, [modules], [config]);
第一个参数,要绑定的元素,第二个参数要绑定的modules ,第三个参数 暂不明确
<!doctype html>
<html >
<body>
<div ng-controller="WelcomeController">
{{greeting}}
</div>
<script src="framework/1.3.0.14/angular.min.js"></script>
<script>
var app = angular.module('demo', [])
.controller('WelcomeController', function($scope) {
$scope.greeting = 'Welcome!';
});
angular.bootstrap(document, ['demo']);
</script>
</body>
</html>
angular.copy(source, [destination]);
复制 操作 source 源(包括任意类型) destination 目的地 (类型和源保持一致)
angular.element(document.querySelector('div')).attr("params","hahha"); 提供类似于jquery的写法,但是用起来不怎么好用,可能自己不太明白,
并且angularjs,不希望直接操控dom
angular.equals(o1, o2);
判断两个值相等 支持值类型、正则表达式、数组和对象。、
angular.extend(obj1,obj2)
合并对象, 将obj2对象合并到obj1。 如果保留obj1写法: angular.extend({},obj1,obj2);
angular.forEach(); 迭代器
案例
var user2={'title':'lisi','passsword':'lisi','centent':'centnt'};
var log=[];
angular.forEach(user2,function(value,key){
console.log(value+"---"+key);
this.push(value,key);
},log)
console.log(log);
angular.fromJson(json);
反序列化 json , 没明白
angular.identity(value);
不懂
angular.injector(modules, [strictDi]);
不明白
angular.isArray(value);
判断是不是数组
angular.isDate();
判断是不是时间类型
angular.isDefined();
判断有没有被引用 ,个人 理解 应该是判断变量定义了有没有赋值
angular.isElement();
判断是不是元素
angular.noop();
不懂
angular.toJson(obj, pretty);
没懂
指令用法
<input type="text" ng-maxlength="20" required name="pname" ng-model="user.PATIENTNAME"/>
<span class="error-tishi" ng-show="!myForm.pname.$valid">*请输入正确姓名</span>
input指令
ng-model 必填项
textarea
和input 指令使用类似
select 标签 里面的 ng-Options 指令 和 类似于ng-reqpeat ,循环数组并将内容填充到 option 元素中。
ng-style 指令 类似于元素 中的style ,优点在于 值,可以设定
ng-bind 指令 和{{}}的区别,ng-bind 显示的变量在angularjs 未加载完成,不会显示
ng-bind-html
指令,功能类似于 jquery 的$().html(); 为元素添加html代码 ,使用之前需要 引入 angular-sanitize.min.js 文件,并且调用服务
var
demoApp=angular.module('demoApp',['ngSanitize']); ngSanitize 服务
ng-bind-template
可以使用 {{}}
[/code][/code]
function
angular.bootstrap(); //猜测是 绑定 ng-app 这个指令的,
angular.bootstrap(element, [modules], [config]);
第一个参数,要绑定的元素,第二个参数要绑定的modules ,第三个参数 暂不明确
<!doctype html>
<html >
<body>
<div ng-controller="WelcomeController">
{{greeting}}
</div>
<script src="framework/1.3.0.14/angular.min.js"></script>
<script>
var app = angular.module('demo', [])
.controller('WelcomeController', function($scope) {
$scope.greeting = 'Welcome!';
});
angular.bootstrap(document, ['demo']);
</script>
</body>
</html>
angular.copy(source, [destination]);
复制 操作 source 源(包括任意类型) destination 目的地 (类型和源保持一致)
angular.element(document.querySelector('div')).attr("params","hahha"); 提供类似于jquery的写法,但是用起来不怎么好用,可能自己不太明白,
并且angularjs,不希望直接操控dom
angular.equals(o1, o2);
判断两个值相等 支持值类型、正则表达式、数组和对象。、
angular.extend(obj1,obj2)
合并对象, 将obj2对象合并到obj1。 如果保留obj1写法: angular.extend({},obj1,obj2);
angular.forEach(); 迭代器
案例
var user2={'title':'lisi','passsword':'lisi','centent':'centnt'};
var log=[];
angular.forEach(user2,function(value,key){
console.log(value+"---"+key);
this.push(value,key);
},log)
console.log(log);
angular.fromJson(json);
反序列化 json , 没明白
angular.identity(value);
不懂
angular.injector(modules, [strictDi]);
不明白
angular.isArray(value);
判断是不是数组
angular.isDate();
判断是不是时间类型
angular.isDefined();
判断有没有被引用 ,个人 理解 应该是判断变量定义了有没有赋值
angular.isElement();
判断是不是元素
angular.noop();
不懂
angular.toJson(obj, pretty);
没懂
指令用法
<input type="text" ng-maxlength="20" required name="pname" ng-model="user.PATIENTNAME"/>
<span class="error-tishi" ng-show="!myForm.pname.$valid">*请输入正确姓名</span>
input指令
ng-model 必填项
textarea
和input 指令使用类似
select 标签 里面的 ng-Options 指令 和 类似于ng-reqpeat ,循环数组并将内容填充到 option 元素中。
ng-style 指令 类似于元素 中的style ,优点在于 值,可以设定
ng-bind 指令 和{{}}的区别,ng-bind 显示的变量在angularjs 未加载完成,不会显示
ng-bind-html
指令,功能类似于 jquery 的$().html(); 为元素添加html代码 ,使用之前需要 引入 angular-sanitize.min.js 文件,并且调用服务
var
demoApp=angular.module('demoApp',['ngSanitize']); ngSanitize 服务
ng-bind-template
可以使用 {{}}
<pre ng-bind-template="{{salutation}} {{name}}!"></pre>[/code]
ng-class指令 接收对象,键为class类名,如果值为true 则加入 ,否则不加入
<p ng-class="{strike: deleted, bold: important, red: error}">Map Syntax Example</p> <input Type="checkbox" ng-model="deleted"> deleted (apply "strike" class)<br>
ng-classEven 配合 ng-repeat 实现奇偶布局
<ol ng-init="names=['John', 'Mary', 'Cate', 'Suz']"> <li ng-repeat="name in names"> <span ng-class-odd="'odd'" ng-class-even="'even'"> {{name}} </span> </li></ol>[/code]
ngCloak 指令,防止angularjs未加载完{{name}} 页面显示问题
[/code][/code]
ng-copy 复制事件 绑定
[/code][/code]ng-cut 剪切事件
[/code][/code]ng-inculude 引入 一段文件
[/code][/code] <div class="slide-animate" ng-include="templates"></div> $scope.templates='./tpls/caseList.html';
[/code][/code]ng-list 不明白含义
[/code][/code]ng-non-bindable 显示源码 对表达式不进行编译
[/code][/code]server服务
[/code][/code]$anchorScroll 滚动到指定服务
[/code][/code]
相关文章推荐
- AngularJS学习笔记(1)
- angularjs和jQuery之checkbox和radio
- Angularjs 实现 $(document).ready()的两种方法
- AngularJS的学习--$on、$emit和$broadcast的使用
- Cordova + Ionic + AngularJS
- AngularJS clone directive 指令复制
- angularJS 常用插件指令
- 一个基于angularJS的工资计算器
- Angularjs 路由之初识
- POJ1948 Triangular Pastures(01背包)
- 简介AngularJS中使用factory和service的方法
- Java B/S系统的颠覆开发Google AngularJs
- angular 语法笔记
- AngularJS最佳实践
- AngularJs的post传递参数action接不到
- Angular2 进阶
- AngularJS分别RequireJS做文件合并压缩的那些坑
- 欧拉项目第12题 Highly divisible triangular number
- 详解Angularjs中的依赖注入
- 【一起学AngularJS】第七章、XHRs和依赖注入