ImageVerifierCode 换一换
你正在下载:

AngularJS.ppt

[预览]
格式:PPT , 页数:22 ,大小:698KB ,
资源ID:378406      下载积分:2000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-378406.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(AngularJS.ppt)为本站会员(花仙子)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

AngularJS.ppt

1、AngularJS,- 简介,liujjgolden-tech,一些概念,客户端模板 Model View Controller(MVC) 数据绑定 依赖注入 指令,liujjgolden-tech,客户端模板,多页面Web应用,AngularJS,+,服务器端装配数据,客户端装配数据,liujjgolden-tech,与目前广泛使用的一些方法相比,有哪些有趣的地方?,liujjgolden-tech,Model View Controller,MVC背后的核心理念 你应该把管理数据的代码(model)、应用逻辑代码(controller)、以及向用户展示数据的代码(view)清晰的分离开 在

2、Angular应用中 视图就是Document Object Model(DOM,文档对象模型) 控制器就是JavaScript类 模型数据则被存储在对象的属性中 MVC非常灵活 对于什么东西应该放在哪里,MVC给了一个思想上的模型,所以不需要每次都来构建这个模型。 使用MVC模型会让应用更加易于扩展、维护和测试,liujjgolden-tech,视图就是Document Object Model(DOM,文档对象模型) 控制器就是JavaScript类 模型数据则被存储在对象的属性中,liujjgolden-tech,数据绑定,声明UI中的某个部分需要映射到某个JavaScript属性,然后

3、让它们自己去同步,这种编程风格叫做数据绑定,liujjgolden-tech,liujjgolden-tech,依赖注入,对于HelloController还有很多东西不需要我们去编写。 例如,进行数据绑定的$scope对象会被自动传递给我们;我们不需要调用任何函数去创建它 $scope并不是我们唯一可以获取的东西($location对象,自定义对象等)。 这种效果是通过Angular的依赖注入机制实现的。 依赖注入让我们遵守这样一种开发风格:我们的类只是简单的获取它们所需要的东西,而不需要创建那些我们所依赖的东西。 这种风格遵循了一种叫做迪米特法则的设计模式,也叫做最小知识原则。,liujj

4、golden-tech,指令,Angular最强大的功能之一就是,你可以把模板编写成HTML的形式。之所以可以做到这一点,是因为我们引入了一款强大的DOM转换引擎,可以用它来扩展HTML的语法 编写成HTML格式有什么好处? 我们已经在之前的例子中看到了一些HTML扩展指令 引入双花括号来实现数据绑定 引入ng-controller来指定每个控制器负责监视视图的哪一部分 引入ng-model用来把输入数据绑定到模型中的一部分属性上 Angular内置了很多指令,并且可以编写自己的指令来扩展HTML模板的功能,liujjgolden-tech,实例:购物车,功能: 1.输入商品数量自动计算价格

5、2.点击删除按钮删除该商品,liujjgolden-tech,Your Shopping CartYour Orderitem.titleitem.price | currencyitem.price * item.quantity | currencyRemovefunction CartController ($scope) $scope.items = title: Paint pots, quantity: 8, price: 3.95,title: Polka dots, quantity: 17, price: 12.95,title: Pebbles, quantity: 5,

6、price: 6.95;$scope.remove = function(index) $scope.items.splice(index, 1);,liujjgolden-tech,Your Shopping CartYour Orderitem.titleitem.price | currencyitem.price * item.quantity | currencyRemovefunction CartController ($scope) $scope.items = title: Paint pots, quantity: 8, price: 3.95,title: Polka d

7、ots, quantity: 17, price: 12.95,title: Pebbles, quantity: 5, price: 6.95;$scope.remove = function(index) $scope.items.splice(index, 1);,ng-app属性用来告诉Angular,页面中的哪一部分需要接受它的管理。 放在标签上,就是告诉Angular,我们希望它管理整个页面。,liujjgolden-tech,Your Shopping CartYour Orderitem.titleitem.price | currencyitem.price * item.q

8、uantity | currencyRemovefunction CartController ($scope) $scope.items = title: Paint pots, quantity: 8, price: 3.95,title: Polka dots, quantity: 17, price: 12.95,title: Pebbles, quantity: 5, price: 6.95;$scope.remove = function(index) $scope.items.splice(index, 1);,在Angular中,使用一种叫做控制器的JavaScript类来管理

9、页面中的区域。 在body标签中引入一个控制器,就是这个声明CartController将会管理介于和之间的所有内容。,liujjgolden-tech,Your Shopping CartYour Orderitem.titleitem.price | currencyitem.price * item.quantity | currencyRemovefunction CartController ($scope) $scope.items = title: Paint pots, quantity: 8, price: 3.95,title: Polka dots, quantity:

10、17, price: 12.95,title: Pebbles, quantity: 5, price: 6.95;$scope.remove = function(index) $scope.items.splice(index, 1);,ng-repeat的意思是,对于items数组中的每一个元素,都把中的DOM结构复制一份(包括div本身)。 对于div的每一份拷贝,都会把一个叫做item的属性设置给它,这样就可以在模板中使用这份拷贝的元素了。,liujjgolden-tech,Your Shopping CartYour Orderitem.titleitem.price | curr

11、encyitem.price * item.quantity | currencyRemovefunction CartController ($scope) $scope.items = title: Paint pots, quantity: 8, price: 3.95,title: Polka dots, quantity: 17, price: 12.95,title: Pebbles, quantity: 5, price: 6.95;$scope.remove = function(index) $scope.items.splice(index, 1);,数据绑定,liujjg

12、olden-tech,Your Shopping CartYour Orderitem.titleitem.price | currencyitem.price * item.quantity | currencyRemovefunction CartController ($scope) $scope.items = title: Paint pots, quantity: 8, price: 3.95,title: Polka dots, quantity: 17, price: 12.95,title: Pebbles, quantity: 5, price: 6.95;$scope.r

13、emove = function(index) $scope.items.splice(index, 1);,双向数据绑定,liujjgolden-tech,Your Shopping CartYour Orderitem.titleitem.price | currencyitem.price * item.quantity | currencyRemovefunction CartController ($scope) $scope.items = title: Paint pots, quantity: 8, price: 3.95,title: Polka dots, quantity

14、: 17, price: 12.95,title: Pebbles, quantity: 5, price: 6.95;$scope.remove = function(index) $scope.items.splice(index, 1);,过滤器(filter):用来转换文本的格式 currency(货币)过滤器:实现美元格式化,liujjgolden-tech,Your Shopping CartYour Orderitem.titleitem.price | currencyitem.price * item.quantity | currencyRemovefunction Car

15、tController ($scope) $scope.items = title: Paint pots, quantity: 8, price: 3.95,title: Polka dots, quantity: 17, price: 12.95,title: Pebbles, quantity: 5, price: 6.95;$scope.remove = function(index) $scope.items.splice(index, 1);,单击按钮调用remove()函数,同时把$index传递过去($index包含了ng-repeat过程中的循环计数),liujjgolden

16、-tech,Your Shopping CartYour Orderitem.titleitem.price | currencyitem.price * item.quantity | currencyRemovefunction CartController ($scope) $scope.items = title: Paint pots, quantity: 8, price: 3.95,title: Polka dots, quantity: 17, price: 12.95,title: Pebbles, quantity: 5, price: 6.95;$scope.remove

17、 = function(index) $scope.items.splice(index, 1);,CartController负责管理购物车的业务逻辑。 在参数的行参中放一个$scope可以告诉Angular:控制器需要一个叫$scope的东西。 我们可以通过$scope把数据绑定到UI元素上。,liujjgolden-tech,Your Shopping CartYour Orderitem.titleitem.price | currencyitem.price * item.quantity | currencyRemovefunction CartController ($scope

18、) $scope.items = title: Paint pots, quantity: 8, price: 3.95,title: Polka dots, quantity: 17, price: 12.95,title: Pebbles, quantity: 5, price: 6.95;$scope.remove = function(index) $scope.items.splice(index, 1);,通过定义$scope.items,创建一个虚拟的hash型数据,用来表示购物车中的项目集合。 想让这些项目能够对UI的数据绑定有效,所以把它们设置到$scope上。,liujjg

19、olden-tech,Your Shopping CartYour Orderitem.titleitem.price | currencyitem.price * item.quantity | currencyRemovefunction CartController ($scope) $scope.items = title: Paint pots, quantity: 8, price: 3.95,title: Polka dots, quantity: 17, price: 12.95,title: Pebbles, quantity: 5, price: 6.95;$scope.remove = function(index) $scope.items.splice(index, 1);,Remove()函数可以只从数组中删除元素。由于ng-repeat所创建的列表都是绑定在数据上的额,所以当数组中的项目消失时,这个列表将会自动收缩。,liujjgolden-tech,

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1