Tejas Rana
  • Home
  • About
  • Experience
  • Skills
  • Blogs
  • Technology
  • Contact
November 21 2015

Basic AngularJS Example, Syntax, calculation

tejas Angular

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

In this basic Tutorial you will learn how to add AngularJS and how to use it.
But before that you must have basic knowledge of:

  • HTML
  • Javascript
  • CSS

AngularJS is a JavaScript Framework

AngularJS is a JavaScript framework. It is a library written in JavaScript.
AngularJS is distributed as a JavaScript file, and can be added to a web page with a script tag:

https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js

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.
Variable syntax:

Example: {{ Name }} or {{ Age }}

 

AngularJS Examples

Simple Hello World:

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="" ng-init="echo='Hello World'">
<p ng-bind="echo"></p>
</div>
</body>
</html>

 
Simple Calculation:

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="">
 	<p>Sum: {{ 1 + 2 }}</p>
 	<p>Multiplication: {{ 2 * 10 }}</p>
 	<p>Division: {{ 10 / 2 }}</p>
        <p>Subtract: {{ 10 - 2 }}</p>
</div>
</body>
</html>

 
Dynamic text binding:

<!DOCTYPE html>
<html>
<script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="">
<p>Name: <input type="text" ng-model="myname" placeholder="Type Your name"></p>
<p>Hi {{myname}}</p>
</div>
</body>
</html>

 
AngularJS filter example using JSON.

AngularJS an Introduction of alternative of Jquery AngularJS Filter Example using JSON

Related Posts

ngrx-behavior

Angular

What is NGRX and Use of NGRX

Angular

What is State Management in Angular? How to improve Performance?

Angular

Angular Typescript Geo Info Module

Categories

  • .NET
  • Android
  • Angular
  • CakePHP
  • CSS
  • Devops
  • Drupal
  • Infi MVC
  • iOS
  • Javascript
  • Magento
  • Meteor
  • MongoDB
  • Opencart
  • Other
  • PHP
  • Python
  • Ruby
  • Tips & Tricks
  • WordPress

Recent Posts

  • Simplify Product Filtering by Category and Store ID in the Admin Panel with Our Powerful OpenCart 3.x Free Extension
  • Opencart 3.x Set currency based on user’s IP [Free Extension]
  • Anatomy of A Coronavirus-Proof Business[Infographic]
  • Opencart 3 Social Login Extension [FREE]
  • What is NGRX and Use of NGRX

Recent Comments

  • Nilesh on What is State Management in Angular? How to improve Performance?
  • Dinesh on Use Magento If You're Serious About eCommerce
  • Virendra on Use Magento If You're Serious About eCommerce
  • Tejas Rana on Show limited words in PHP from string with HTML tags
  • nadim on Show limited words in PHP from string with HTML tags
Tejas Rana
© Tejas Rana 2025