Skip to content
-
Subscribe to our newsletter & never miss our best posts. Subscribe Now!
Technical Personnal Blog

Technical Personnal Blog

Technical Personnal Blog

Technical Personnal Blog

  • Tech
  • Blog
  • Open Source
  • VEGAS
  • CARD
  • Favorite Link
  • Shop
  • Cart
  • Checkout
  • My account
  • Tech
  • Blog
  • Open Source
  • VEGAS
  • CARD
  • Favorite Link
  • Shop
  • Cart
  • Checkout
  • My account
Close

Search

  • https://www.facebook.com/
  • https://twitter.com/
  • https://t.me/
  • https://www.instagram.com/
  • https://youtube.com/
Subscribe
BlogTech

AngularJS Introduction

By techsupport
June 24, 2016 2 Min Read
Comments Off on AngularJS Introduction

AngularJS is a JavaScript framework. It can be added to an HTML page with a <script> tag.

AngularJS extends HTML attributes with Directives, and binds data to HTML with Expressions.

AngularJS Extends HTML

AngularJS extends HTML with ng-directives.

The ng-app directive defines an AngularJS application.

The ng-model directive binds the value of HTML controls (input, select, textarea) to application data.

The ng-bind directive binds application data to the HTML view

<!DOCTYPE html>
<html>
<script src=”http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js”></script>
<body>

<div ng-app=””>
<p>Name: <input type=”text” ng-model=”name”></p>
<p ng-bind=”name”></p>
</div>

</body>
</html>

Example explained:

AngularJS starts automatically when the web page has loaded.

The ng-app directive tells AngularJS that the <div> element is the “owner” of an AngularJS 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 <p> element to the application variable name.

 

AngularJS Directives

As you have already seen, AngularJS directives are HTML attributes with an ng prefix.

The ng-init directive initializes AngularJS application variables.

 

<div ng-app=”” ng-init=”firstName=’John'”>

<p>The name is <span ng-bind=”firstName”></span></p>

</div>

 

AngularJS Expressions

AngularJS expressions are written inside double braces: {{ expression }}.

AngularJS will “output” data exactly where the expression is written:

 

<!DOCTYPE html>
<html>
<script src=”http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js”></script>
<body>

<div ng-app=””>
<p>My first expression: {{ 5 + 5 }}</p>
</div>

</body>
</html>

 

<!DOCTYPE html>
<html>
<script src=”http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js”></script>
<body>

<div ng-app=””>
<p>Name: <input type=”text” ng-model=”name”></p>
<p>{{name}}</p>
</div>

</body>
</html>

AngularJS Applications

AngularJS modules define AngularJS applications.

AngularJS controllers control AngularJS applications.

The ng-app directive defines the application, the ng-controller directive defines the controller.

<div ng-app=”myApp” ng-controller=”myCtrl“>

First Name: <input type=”text” ng-model=”firstName”><br>
Last Name: <input type=”text” ng-model=”lastName”><br>
<br>
Full Name: {{firstName + ” ” + lastName}}

</div>

<script>
var app = angular.module(‘myApp‘, []);
app.controller(‘myCtrl‘, function($scope) {
$scope.firstName= “John”;
$scope.lastName= “Doe”;
});
</script>

Author

techsupport

Follow Me
Other Articles
Previous

This Tutorial

Next

[통계로 보는 위챗] 중국 최대 메신저 ‘위챗’, ‘위챗페이’의 모든 것

Categories

  • Android
  • Blog
  • Favorite Link
  • linux
  • Open Source
  • opencart
  • social
  • Tech
  • Uncategorized

Archives

  • January 2025
  • March 2024
  • August 2023
  • March 2023
  • February 2023
  • November 2021
  • August 2021
  • April 2021
  • March 2021
  • December 2020
  • October 2020
  • September 2020
  • July 2020
  • June 2020
  • May 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • September 2019
  • August 2019
  • June 2019
  • October 2018
  • August 2018
  • May 2018
  • April 2018
  • March 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • June 2017
  • March 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • January 2016
  • December 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
Copyright 2026 — Technical Personnal Blog. All rights reserved. Blogsy WordPress Theme