AngularJS: An Overview

AngularJS: An Overview

By Paras Babbar on Apr 21, 2015

Introduction

Angular JS is a very powerful JavaScript library or we can say open-source web application framework maintained by Google. It is used in Single Page Application (SPA) projects. It extends the HTML DOM with additional attributes (in other words directives) and binds data to HTML with expressions, hence making it more responsive to user actions.

It is licensed under the Apache version 2.0 license.

Prerequisites

One should have a basic understanding of JavaScript and any text editor (I‘ll be using Visual Studio 2015). Since we are developing web-based applications using Angular JS, knowledge of HTML, CSS and AJAX will be an advantage.

Let‘s consider the following example:

  1. <!-- Angular JS Example -->
  2. <div ng-app="">
  3. <p>
  4. <b>Name:</b> <input type="text" ng-model="name" />
  5. </p>
  6. <h2 ng-bind="name">
  7. </h2>
  8. </div>

Angular JS extends HTML with ng-directives.

  • The ng-app directive defines an Angular JS application.
  • The ng-model directive binds the value of HTML controls (input, select and text area) to application data.
  • The ng-bind directive binds application data to the HTML view.

Complete Code

  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Angular JS 1</title>
  5. <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
  6. </head>
  7. <body>
  8. <!-- Angular JS Example -->
  9. <div ng-app="">
  10. <p>
  11. <b>Name:</b> <input type="text" ng-model="name" />
  12. </p>
  13. <h2 ng-bind="name">
  14. </h2>
  15. </div>
  16. </body>
  17. </html>

Example Explained

Angular JS starts automatically when the webpage has loaded.

  • The ng-app directive tells Angular JS that the <div> element is the “owner” of an Angular JS application.
  • The ng-model directive binds the value of the input field to the application variable name.
  • The ng-bind directive binds the innerHTML of the <h2> element to the application variable name.

Output

Note: You can use data-ng-, instead of ng-, if you want to make your page HTML 5 valid.

You‘ll get more to be familiar with Angular JS in a future article. Keep visiting

src: http://www.c-sharpcorner.com/UploadFile/cb92fb/angularjs-an-overview/

时间: 2024-10-29 19:10:26

AngularJS: An Overview的相关文章

AngularJs learning notes overview

建议把脚本放在<body> 元素的底部.这会提高网页加载速度,因为 HTML 加载不受制于脚本加载. 2. AngularJS 通过ng-directives 扩展了HTML. ng-app 指令定义一个AngularJS 应用程序.(如果您移除了ng-app指令,HTML将直接把表达式显示出来,不会去计算表达式的结果.) ng-model 指令把元素值(比如输入域的值)绑定到应用程序.(likethe index of input value) ng-bind 指令把应用程序数据绑定到HTM

angularjs路由path方式实现原理探究

angularjs路由 https://angular.io/guide/router 通过URL解释, 来定位客户端生成的浏览器端视图. 你可绑定路由到页面的链接上, 当用户点击链接, 可以浏览到相应的应用视图. The browser is a familiar model of application navigation: Enter a URL in the address bar and the browser navigates to a corresponding page. C

AngularJS 学习笔记(1)

AngularJS是一款前端JS框架.AngularJS官网 http://angularjs.org [开发环境准备]: 1,下载AngularJS:JS and CSS in Solution 2,编辑器 WebStorm,下载地址:https://www.jetbrains.com/webstorm/  (配合最新版JetBrains使用,可以即时无刷新显示更新代码后的效果) 3,下载最新版Chrome,并安装扩展程序:JetBrains IDE Suport,(需要FQ) 下载地址:ht

AngularJS 学习

AngularJS 学习笔记(1) AngularJS是一款前端JS框架.AngularJS官网 http://angularjs.org [开发环境准备]: 1,下载AngularJS:JS and CSS in Solution 2,编辑器 WebStorm,下载地址:https://www.jetbrains.com/webstorm/  (配合最新版JetBrains使用,可以即时无刷新显示更新代码后的效果) 3,下载最新版Chrome,并安装扩展程序:JetBrains IDE Sup

[转]Using MVC 6 And AngularJS 2 With .NET Core

本文转自:http://www.c-sharpcorner.com/article/using-mvc-6-and-angularjs-2-with-net-core/ CoreMVCAngular2.zip Download 100% FREE Spire Office APIs In this article, Setup Environment. Overview on ASP.NET. Start with .NET Core 1.0. Explore Initial Template

购物车Demo,前端使用AngularJS,后端使用ASP.NET Web API(1)--后端

原文:购物车Demo,前端使用AngularJS,后端使用ASP.NET Web API(1)--后端 chsakell分享了前端使用AngularJS,后端使用ASP.NET Web API的购物车案例,非常精彩,这里这里记录下对此项目的理解. 文章:http://chsakell.com/2015/01/31/angularjs-feat-web-api/http://chsakell.com/2015/03/07/angularjs-feat-web-api-enable-session-

AngularJS -- HTML 编译器

HTML Compiler Overview(HTML 编译器 概要) AngularJS 的HTML编译器允许开发人员教浏览器一些新的HTML语法.编译器还允许你去附加行为(包括你自定义的)到任何的HTML元素或者属性,甚至是你自己创建的新的HTML元素或者属性上去.是不是很强大,是不是很鸡冻啊? *^_^*    AngularJS会在扩展的指令中,去调用这些行为. 有很多时尚的声明式的方式去格式化HTML静态文档.比如,有个对象需要居中显示,我们不需要提供一个方法,告诉浏览器,当窗口变化的

【转】Build Your own Simplified AngularJS in 200 Lines of JavaScript

原文:http://blog.mgechev.com/2015/03/09/build-learn-your-own-light-lightweight-angularjs/ Build Your own Simplified AngularJS in 200 Lines of JavaScript Edit My practice proved that there are two good/easy ways to learn a new technology: Re-implement i

【Nodejs&amp;&amp;ExpressJS&amp;&amp;AngularJS】安装与框架搭建

1.NodeJS 下载安装包 https://nodejs.org/download/ 安装安装包 tar --strip-components 1 -xzvf node-v0.12.1-linux-x64.tar.gz -C /opt/app/nodejs_12 2.安装开发包 npm install -g express npm install -g express-generator npm install -g yo npm install -g generator-angular np