一。AngularJS 是一个 JavaScript 框架。它可通过 <script> 标签添加到 HTML 页面。
例如:
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
这是通过网址自动加载的,也可以去下载文件,然后用上面的方式加载进去。
下载地址:https://github.com/angular/angular.js/releases
说明:AngularJS只有一个主页面,其他的页面都是通过加载在主页面里面的,通俗点说就是只有一个页面,多个页面的效果是通过局部进行加载的。
二。AngularJS表达式:是以 {{ 表达式 }} 双大括号的形式进行书写的。
三。AngularJS 指令:
ng-app 指令初始化一个 AngularJS 应用程序。
ng-init 指令初始化应用程序数据。
ng-model 指令把元素值(比如输入域的值)绑定到应用程序。
ng-bind 指令绑定 HTML 元素到应用程序数据
ng-repeat 指令会重复一个 HTML 元素
上面的是比较常用的指令。
下面是一个具体的例子:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script> </head> <body ng-app> //ng-app:定义AngularJS跟元素 <div ng-init="names=[ //ng-init:用来赋予names值 {name:'apple',price:'3'}, {name:'orange',price:'2.5'}, {name:'banana',price:'3.5'}]"> <p>循环对象:</p> <ul> <li ng-repeat="x in names"> //ng-repeat:指令对于数组中的每个项会克隆一次HTML元素 {{ x.name + ' : ' + x.price }}</li> </ul> <h2 ng-init='quantity=0;price=0'>价格计算器</h2> 数量: <input type="number" ng-model="quantity"> //ng-model:绑定 HTML 元素 到应用程序数据 价格: <input type="number" ng-model="price"> <p><b>总价:</b> {{quantity * price}}</p> </div> </body> </html>
四。Angular模型:ng-model指令。
双向绑定。 例如:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script> </head> <body> <div ng-app="myApp" ng-controller="myCtrl"> 名字: <input ng-model="name"> <h1>你输入了: {{name}}</h1> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.name = "大神"; }); </script> <p>修改输入框的值,标题的名字也会相应修改。</p> </body> </html>
上面就是Angular最基本的知识。如果只是想了解AngularJS,希望这篇文章能够让大家有个基础的理解。
相关推荐
《精通AngularJS》深入浅出地讲解了AngularJS的开发概念和原理,并通过丰富的开发实例向读者展示了构建复杂应用的完整过程,包括学习使用AngularJS特有的基于DOM的模板系统,实现复杂的后端通信,创建漂亮的表单,...
AngularJS: Novice to Ninja is the perfect book to journey into the world of AngularJS, the superheroic JavaScript framework. Developed and maintained by Google, AngularJS brings the Model-View-...
AngularJS是一款优秀的前端JS框架,已经被用于Google的多款产品当中,并且得到众多前端工程师的青睐。, 《AngularJS高级程序设计》是AngularJS程序设计的高级指南。全书共25章,分为3个部分,每部分覆盖一组相关话题...
两本书的pdf:AngularJS中文版+精通AngularJS,提供方式:百度云链接+密码
Use a Material Design approach to position elements and create animations along with principles of the sophisticated AngularJS JavaScript framework. Take advantage of Angular Material, a UI component ...
<最新AngularJS开发宝典视频教程> ├最新AngularJS开发宝典—第001讲 什么是Angular及与Jquery实例对比分析.mp4 ├最新AngularJS开发宝典—第002讲 模块、控制器、视图模型、双向数据绑定模型、双向数据绑定.mp4 ├...
(精通AngularJS)Mastering Web Application Development with AngularJS code 源代码
Get introduced to the key features of AngularJS and understand its role in responsive design Learn various approaches for responsive web application development Discover practical examples to ...
AngularJS_权威教程.pdf AngularJS_深度剖析与最佳实践.pdf
这个我花了很大功夫下载的、是真正完整的、不做任何修改的、直接从官网下载的AngularJS的完整开发包(带文档)。具体的下载来源地址是https://code.angularjs.org/1.2.25/angular-1.2.25.zip。程序员不用太辛苦找...
A comprehensive guide to AngularJS, Google's open-source client-side framework for app development. Most of the existing guides to AngularJS struggle to provide simple and understandable explanations...
资源名称:AngularJS的介绍与研究 中文PPT版内容简介:AngularJS是一个前端的框架,跟后台的spring、struts框架类似,可以帮助我们快速的搭建和开发前端项目。与jquery等前端框架不同,AngularJS不仅仅是一个工具,...
本书是学习 AngularJS 的公认经典,内容全面,讲解通俗,适合各层次的学习者。作者拥有丰富的 AngularJS 开发和教学经验,也是一位全栈工程师。全书 35 章,由浅入深地讲解了 AngularJS 的基本概念和 基本功能,包括...
angularJS router filter service diractive
适合于AngularJS初学者
AngularJS Eclipse 插件为Eclipse提供对AngularJS的支持
AngularJS 开发 ASP.NET MVC.
AngularJS[1] 诞生于2009年,由Misko Hevery 等人创建,后为Google所收购。是一款优秀的前端JS框架,已经被用于Google的多款产品当中。AngularJS有着诸多特性,最为核心的是:MVC、模块化、自动化双向数据绑定、语义...
spring springmvc mybatis bootstart angularjs简单案例,入门级
AngularJS高级程序设计[3]