SlideShare a Scribd company logo
1 of 31
Download to read offline
Angularjs
A client side javascript framework for adding
interactivity to HTML

The resulting environment is extraordinarily
expressive, readable, and quick to develop.
− Extensibility

AngularJS is a toolset for building the framework most suited to your application
development. It is fully extensible and works well with other libraries.

Every feature can be modified or replaced to suit your unique development
workflow and feature needs.
.

DIRECTIVES-HTML annotations that trigger
javascript behaviors

MODULES- our application components
live(present)

CONTROLLERS- here, we add application
behavior

EXPRESSIONS- values are displayed from here
with in a page.
Directive

It is a marker on HTML tag that tells angular to
run or reference some javascript code

Index.html
<!DOCTYPE html>
<html>
<body ng-
controller=”store
controller”>
</body>
</html>
App.js
Function storeController(){
Alert('welcome,ravi!');
}
Index.html
Name of function to call
Output
Welcome,ravi
!
libraries
MODULES

Here, we write our pieces of angular application

Makes our code more maintainable,testable and
readable

Here we define dependencies for our app

Modules can use other modules

Var app = angular.module('store',[ ]);
Application name dependencies
Including the module
Expressions

Allows you to insert Dynamic values into html

String operations

Numerical operations
<p>
I am {{4+6}}
</p>
<p>
I am 10
</p>
Evaluates to
{{“hello”+”you”}} Hello you
Controllers

Controllers are where we define our app's
behaviour by defining functions & values.

//

(function(){

var app = angular.module('store',[ ]);

app.controller('StoreController',function(){

});

})();
//Controller is attached inside our app//
HTML
Adding Controller to HTML
Ng-show directive
Ng-hide
Usage of Arrays
Arrays to display multiple
values
Repeat
This steps
For each
product
MVC

In MVC ,a clear separation in the code between

managing data(model),

application logic(controller)

presentation to user (view)

In Angular,view is the DOM (Document object
model),

Controllers are javascript classes &

Model data stored in object properties.
DOM(Document Object Model)

DOM is an application programming interface
(API) for valid HTML and well-formed XML
documents.

It defines the logical structure of documents and
the way a document is accessed and
manipulated,*Provides standard prog.interface.

With DOM, programmers can build documents,
navigate their structure, and add, modify, or
delete elements and content. Anything found in
an HTML or XML document can be accessed,
changed, deleted, or added using the DOM, with
a few exceptions
Dependency Injection

Dependency Injection (DI) is a software design pattern that deals
with how components get hold of their dependencies.

The Angular injector subsystem is in charge of creating
components, resolving their dependencies, and providing them to
other components as requested.

Eg:
function HelloController($scope, $location) {
$scope.greeting = { text: 'Hello' };
}
DI in a brief
There are only three ways a component (object or function) can get a
hold of its dependencies:
I. The component can create the dependency, typically using the
new operator.
II. The component can look up the dependency, by referring to a
global variable.
III. The component can have the dependency passed to it where it is
needed.
I. DI IS UDED AT:
II. Factory methods ,Module methods & Controllers
DI

.
Bootstrap
Bootstrapping is the equivalent of initializing, or starting, your
Angular app.

There are 2 main ways to do so.

The first is automatically bootstrapping by adding ng-app to the an
element in your HTML, like so:

<html ng-app="myApp">

...

</html>

The second would be to bootstrap from the JavaScript, like so,
after having creating your app through

angular.module("myApp", []):

angular.bootstrap(document, ['myApp']);
Automatic initialization

Angular initializes automatically upon DOMContentLoaded event or when
the angular.js script is evaluated if at that time document.readyState is set
to 'complete'. At this point Angular looks for the ng-app directive which
designates your application root. If the ng-app directive is found then
Angular will:
I. load the module associated with the directive.
II. create the application injector
III. compile the DOM treating the ng-app directive as the root of the
compilation. This allows you to tell it to treat only a portion of the
DOM as an Angular application.
IV. <!doctype html>
V. <html ng-app="optionalModuleName">
VI. <body>
VII. I can add: {{ 1+2 }}.
VIII. <script src="angular.js"></script>
IX. </body>
Manual Initialization
If you need to have more control over the initialization process, you can
use a manual bootstrapping method instead. Examples of when you'd
need to do this include using script loaders or the need to perform an
operation before Angular compiles a page.

<!doctype html>

<html> <body>

Hello {{'World'}}!

<script src="http://code.angularjs.org/snapshot/angular.js"></script>

<script>

angular.module('myApp', [])

.controller('MyController', ['$scope', function ($scope) {

$scope.greetMe = 'World';

}]);

angular.element(document).ready(function() {

angular.bootstrap(document, ['myApp']);

});
You should not use the ng-app
directive when manually
bootstrapping your app.
Data Binding
Data-binding in Angular apps is the automatic synchronization of data
between the model and view components.
The view is a projection of the model at all times. When the model
changes, the view reflects the change, and vice versa.
First the template (which is the uncompiled HTML along with any additional markup or directives) is
compiled on the browser.

The compilation step produces a live view. Any changes to the view are immediately reflected in
the model, and any changes in the model are propagated to the view.

The model is the single-source-of-truth for the application state, greatly simplifying the
programming model for the developer.

You can think of the view as simply an instant projection of your model.

the controller is completely separated from the view and unaware of it.

This makes testing a snap because it is easy to test your controller in isolation without the view
and the related DOM/browser dependency.
Data binding
2-way databinding vs 1-way databinding.
CSS classes used by Angular
Ng-scope:
Usage: angular applies this class to any element for which a new scope is defined.
Ng-binding:
Usage: angular applies this class to any element that is attached to a data binding, via ng-bind or {{}} curly braces
ng-invalid, ng-valid:
Usage: angular applies this class to an input widget element if that element's input does not pass validation.
ng-pristine, ng-dirty:
Usage: angular input directive applies ng-pristine class to a new input widget element which did not have user interaction. Once the user
interacts with the input widget the class is changed to ng-dirty.
Forms
. A Form is a collection of controls for the purpose of grouping related controls together.
Form and controls provide validation services, so that the user can be notified of invalid input.
This provides a better user experience, because the user gets instant feedback on how to
correct the error.
A form is an instance of FormController. The form instance can optionally be published into
the scope using the name attribute.
Similarly, an input control that has the ngModel directive holds an instance of
NgModelController. Such a control instance can be published as a property of the form
instance using the name attribute on the input control. The name attribute specifies the
name of the property on the form instance.
This implies that the internal state of both the form and the control is available for binding in
the view using the standard binding primitives.
Custom triggers
By default, any change to the content will trigger a model update and form validation. You
can override this behavior using the ngModelOptions directive to bind only to specified
list of events. I.e. ng-model-options="{ updateOn: 'blur' }" will update and validate only
after the control loses focus.
Example: //Changes on the inputs within the form will update the model only//
Index.html
<div ng-controller="ExampleController">
<form>
Name:
<input type="text" ng-model="user.name" ng-model-options="{ updateOn: 'blur' }" /><br />
Other data:
<input type="text" ng-model="user.data" /><br />
</form>
<pre>username = "{{user.name}}"</pre>
</div>
Script.js
angular.module('customTriggerExample', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.user = {};
}]);
Custom Validation

Angular provides basic implementation for most common html5 input types: (text,
number, url, email, radio, checkbox), as well as some directives for validation (required,
pattern, minlength, maxlength, min, max).

Defining your own validator can be done by defining your own directive which adds a
custom validation function to the ngModel controller. To get a hold of the controller the
directive specifies a dependency

Validation occurs in 2 places

Model to View update - Whenever the bound model changes, all functions in
NgModelController#$formatters array are pipe-lined, so that each of these functions
has an opportunity to format the value and change validity state of the form control
through NgModelController#$setValidity

View to Model update - In a similar way, whenever a user interacts with a control it
calls NgModelController#$setViewValue. This in turn pipelines all functions in the
NgModelController#$parsers array, so that each of these functions has an
opportunity to convert the value and change validity state of the form control through
NgModelController#$setValidity.
Implementing custom form controls
(using ngModel)

Angular implements all of the basic HTML form controls (input, select, textarea), which
should be sufficient for most cases. However, if you need more flexibility, you can write
your own form control as a directive.

In order for custom control to work with ngModel and to achieve two-way data-binding it
needs to:

implement $render method, which is responsible for rendering the data after it passed
the NgModelController#$formatters,

call $setViewValue method, whenever the user interacts with the control and model
needs to be updated. This is usually done inside a DOM Event listener.

Eg:

<div contentEditable="true" ng-model="content" title="Click to edit">Some</div>
FILTERS
A filter formats the value of an expression for display to the user. They can be used in view
templates, controllers or services and it is easy to define your own FILTER.
Using filters in view templates
Filters can be applied to expressions in view templates using the following syntax:
{{ expression | filter }}
CHAINING FILTERS : {{ expression | filter1 | filter2 | ... }}
FILTERS WITH ARGUMENTS: {{ expression | filter:argument1:argument2:... }}
filters in controllers, services, and directives.
For this, inject a dependency with the name <filterName>Filter T.o your
controller/service/directive. E.g. using the dependency numberFilter will inject the number
filter. The injected argument is a function that takes the value to format as first argument
and filter parameters starting with the second argument.
EXAMPLE
INDEX.HTML
<div ng-controller="FilterController as ctrl">
<div>
All entries:
<span ng-repeat="entry in ctrl.array">{{entry.name}} </span>
</div>
<div>
Entries that contain an "a":
<span ng-repeat="entry in ctrl.filteredArray">{{entry.name}} </span>
</div>
</div>
SCRIPT.JS
angular.module('FilterInControllerModule', []).
controller('FilterController', ['filterFilter', function(filterFilter) {
this.array = [
{name: 'Tobias'},
{name: 'Jeff'},
{name: 'Brian'},
{name: 'Igor'},
{name: 'James'},
{name: 'Brad'}
];
this.filteredArray = filterFilter(this.array, 'a');
}]);
All entries: Tobias Jeff Brian Igor James Brad

More Related Content

What's hot

Different way to share data between controllers in angular js
Different way to share data between controllers in angular jsDifferent way to share data between controllers in angular js
Different way to share data between controllers in angular jscodeandyou forums
 
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumarIntroduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumarAppfinz Technologies
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsRapidValue
 
Angular.js interview questions
Angular.js interview questionsAngular.js interview questions
Angular.js interview questionscodeandyou forums
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesMohamad Al Asmar
 
Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introductionLuigi De Russis
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introductionTania Gonzales
 
Angular Js Advantages - Complete Reference
Angular Js Advantages - Complete ReferenceAngular Js Advantages - Complete Reference
Angular Js Advantages - Complete ReferenceEPAM Systems
 
Introduction to Google Guice
Introduction to Google GuiceIntroduction to Google Guice
Introduction to Google GuiceKnoldus Inc.
 
Jug Guice Presentation
Jug Guice PresentationJug Guice Presentation
Jug Guice PresentationDmitry Buzdin
 
Using Page Objects
Using Page ObjectsUsing Page Objects
Using Page ObjectsGetch88
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular jsTamer Solieman
 
Angular Project Report
 Angular Project Report Angular Project Report
Angular Project ReportKodexhub
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionDive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionOleksii Prohonnyi
 

What's hot (20)

Introduction to Angular Js
Introduction to Angular JsIntroduction to Angular Js
Introduction to Angular Js
 
Different way to share data between controllers in angular js
Different way to share data between controllers in angular jsDifferent way to share data between controllers in angular js
Different way to share data between controllers in angular js
 
Angular from Scratch
Angular from ScratchAngular from Scratch
Angular from Scratch
 
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumarIntroduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumar
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
 
AngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue SolutionsAngularJS Project Setup step-by- step guide - RapidValue Solutions
AngularJS Project Setup step-by- step guide - RapidValue Solutions
 
Angular.js interview questions
Angular.js interview questionsAngular.js interview questions
Angular.js interview questions
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key Features
 
Angular 8
Angular 8 Angular 8
Angular 8
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
 
Angular Js Advantages - Complete Reference
Angular Js Advantages - Complete ReferenceAngular Js Advantages - Complete Reference
Angular Js Advantages - Complete Reference
 
Angular js
Angular jsAngular js
Angular js
 
Introduction to Google Guice
Introduction to Google GuiceIntroduction to Google Guice
Introduction to Google Guice
 
Jug Guice Presentation
Jug Guice PresentationJug Guice Presentation
Jug Guice Presentation
 
Using Page Objects
Using Page ObjectsUsing Page Objects
Using Page Objects
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
Angular Project Report
 Angular Project Report Angular Project Report
Angular Project Report
 
5 angularjs features
5 angularjs features5 angularjs features
5 angularjs features
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionDive into Angular, part 1: Introduction
Dive into Angular, part 1: Introduction
 

Viewers also liked

AngularJS - dependency injection
AngularJS - dependency injectionAngularJS - dependency injection
AngularJS - dependency injectionAlexe Bogdan
 
AngularJS intro
AngularJS introAngularJS intro
AngularJS introdizabl
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedStéphane Bégaudeau
 
Dependency Injection pattern in Angular
Dependency Injection pattern in AngularDependency Injection pattern in Angular
Dependency Injection pattern in AngularAlexe Bogdan
 
Angular custom directives
Angular custom directivesAngular custom directives
Angular custom directivesAlexe Bogdan
 
ngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionDzmitry Ivashutsin
 
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDBDynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDBApaichon Punopas
 
Angular js
Angular jsAngular js
Angular jsmiladiir
 
Gettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSGettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSArmin Vieweg
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJSRan Mizrahi
 

Viewers also liked (13)

AngularJS - dependency injection
AngularJS - dependency injectionAngularJS - dependency injection
AngularJS - dependency injection
 
AngularJS intro
AngularJS introAngularJS intro
AngularJS intro
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
Dependency Injection pattern in Angular
Dependency Injection pattern in AngularDependency Injection pattern in Angular
Dependency Injection pattern in Angular
 
Angular custom directives
Angular custom directivesAngular custom directives
Angular custom directives
 
Ajs ppt
Ajs pptAjs ppt
Ajs ppt
 
ngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency InjectionngMess: AngularJS Dependency Injection
ngMess: AngularJS Dependency Injection
 
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDBDynamic Application Development by NodeJS ,AngularJS with OrientDB
Dynamic Application Development by NodeJS ,AngularJS with OrientDB
 
Angular js
Angular jsAngular js
Angular js
 
Gettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSGettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJS
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
Dependency Injection @ AngularJS
Dependency Injection @ AngularJSDependency Injection @ AngularJS
Dependency Injection @ AngularJS
 
Angularjs
AngularjsAngularjs
Angularjs
 

Similar to introduction to Angularjs basics

Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseEPAM Systems
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014Ran Wahle
 
Angular js interview question answer for fresher
Angular js interview question answer for fresherAngular js interview question answer for fresher
Angular js interview question answer for fresherRavi Bhadauria
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs WorkshopRan Wahle
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development GuideNitin Giri
 
ANGULAR JS LAB MANUAL(final) vtu2021 sch
ANGULAR JS LAB MANUAL(final) vtu2021 schANGULAR JS LAB MANUAL(final) vtu2021 sch
ANGULAR JS LAB MANUAL(final) vtu2021 schkannikadg
 
One Weekend With AngularJS
One Weekend With AngularJSOne Weekend With AngularJS
One Weekend With AngularJSYashobanta Bai
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS BasicsRavi Mone
 
GDG Atlanta - Angular.js Demo and Workshop
GDG Atlanta - Angular.js Demo and WorkshopGDG Atlanta - Angular.js Demo and Workshop
GDG Atlanta - Angular.js Demo and WorkshopDrew Morris
 
Leveling up with AngularJS
Leveling up with AngularJSLeveling up with AngularJS
Leveling up with AngularJSAustin Condiff
 
Kalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework Yakov Fain
 
angularjs_tutorial.docx
angularjs_tutorial.docxangularjs_tutorial.docx
angularjs_tutorial.docxtelegramvip
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIEric Wise
 

Similar to introduction to Angularjs basics (20)

Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
 
Angular js interview question answer for fresher
Angular js interview question answer for fresherAngular js interview question answer for fresher
Angular js interview question answer for fresher
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
 
ANGULAR JS LAB MANUAL(final) vtu2021 sch
ANGULAR JS LAB MANUAL(final) vtu2021 schANGULAR JS LAB MANUAL(final) vtu2021 sch
ANGULAR JS LAB MANUAL(final) vtu2021 sch
 
One Weekend With AngularJS
One Weekend With AngularJSOne Weekend With AngularJS
One Weekend With AngularJS
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
GDG Atlanta - Angular.js Demo and Workshop
GDG Atlanta - Angular.js Demo and WorkshopGDG Atlanta - Angular.js Demo and Workshop
GDG Atlanta - Angular.js Demo and Workshop
 
Angular js-crash-course
Angular js-crash-courseAngular js-crash-course
Angular js-crash-course
 
Leveling up with AngularJS
Leveling up with AngularJSLeveling up with AngularJS
Leveling up with AngularJS
 
Starting with angular js
Starting with angular js Starting with angular js
Starting with angular js
 
Angular js
Angular jsAngular js
Angular js
 
Kalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js Tutorials
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
AngularJS
AngularJS AngularJS
AngularJS
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
 
angularjs_tutorial.docx
angularjs_tutorial.docxangularjs_tutorial.docx
angularjs_tutorial.docx
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPI
 
AngularJS
AngularJSAngularJS
AngularJS
 

Recently uploaded

Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
DBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfDBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfChristalin Nelson
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroomSamsung Business USA
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipKarl Donert
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...Nguyen Thanh Tu Collection
 
Objectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptxObjectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptxMadhavi Dharankar
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6Vanessa Camilleri
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 

Recently uploaded (20)

Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
CARNAVAL COM MAGIA E EUFORIA _
CARNAVAL COM MAGIA E EUFORIA            _CARNAVAL COM MAGIA E EUFORIA            _
CARNAVAL COM MAGIA E EUFORIA _
 
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
Mattingly "AI & Prompt Design" - Introduction to Machine Learning"
 
Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
Plagiarism,forms,understand about plagiarism,avoid plagiarism,key significanc...
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
DBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfDBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdf
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
Chi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical VariableChi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical Variable
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenship
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Objectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptxObjectives n learning outcoms - MD 20240404.pptx
Objectives n learning outcoms - MD 20240404.pptx
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 

introduction to Angularjs basics

  • 1. Angularjs A client side javascript framework for adding interactivity to HTML  The resulting environment is extraordinarily expressive, readable, and quick to develop. − Extensibility  AngularJS is a toolset for building the framework most suited to your application development. It is fully extensible and works well with other libraries.  Every feature can be modified or replaced to suit your unique development workflow and feature needs.
  • 2. .  DIRECTIVES-HTML annotations that trigger javascript behaviors  MODULES- our application components live(present)  CONTROLLERS- here, we add application behavior  EXPRESSIONS- values are displayed from here with in a page.
  • 3. Directive  It is a marker on HTML tag that tells angular to run or reference some javascript code  Index.html <!DOCTYPE html> <html> <body ng- controller=”store controller”> </body> </html> App.js Function storeController(){ Alert('welcome,ravi!'); } Index.html Name of function to call Output Welcome,ravi !
  • 5. MODULES  Here, we write our pieces of angular application  Makes our code more maintainable,testable and readable  Here we define dependencies for our app  Modules can use other modules  Var app = angular.module('store',[ ]); Application name dependencies
  • 7. Expressions  Allows you to insert Dynamic values into html  String operations  Numerical operations <p> I am {{4+6}} </p> <p> I am 10 </p> Evaluates to {{“hello”+”you”}} Hello you
  • 8. Controllers  Controllers are where we define our app's behaviour by defining functions & values.  //  (function(){  var app = angular.module('store',[ ]);  app.controller('StoreController',function(){  });  })(); //Controller is attached inside our app//
  • 13. Usage of Arrays Arrays to display multiple values Repeat This steps For each product
  • 14. MVC  In MVC ,a clear separation in the code between  managing data(model),  application logic(controller)  presentation to user (view)  In Angular,view is the DOM (Document object model),  Controllers are javascript classes &  Model data stored in object properties.
  • 15. DOM(Document Object Model)  DOM is an application programming interface (API) for valid HTML and well-formed XML documents.  It defines the logical structure of documents and the way a document is accessed and manipulated,*Provides standard prog.interface.  With DOM, programmers can build documents, navigate their structure, and add, modify, or delete elements and content. Anything found in an HTML or XML document can be accessed, changed, deleted, or added using the DOM, with a few exceptions
  • 16. Dependency Injection  Dependency Injection (DI) is a software design pattern that deals with how components get hold of their dependencies.  The Angular injector subsystem is in charge of creating components, resolving their dependencies, and providing them to other components as requested.  Eg: function HelloController($scope, $location) { $scope.greeting = { text: 'Hello' }; }
  • 17. DI in a brief There are only three ways a component (object or function) can get a hold of its dependencies: I. The component can create the dependency, typically using the new operator. II. The component can look up the dependency, by referring to a global variable. III. The component can have the dependency passed to it where it is needed. I. DI IS UDED AT: II. Factory methods ,Module methods & Controllers
  • 19. Bootstrap Bootstrapping is the equivalent of initializing, or starting, your Angular app.  There are 2 main ways to do so.  The first is automatically bootstrapping by adding ng-app to the an element in your HTML, like so:  <html ng-app="myApp">  ...  </html>  The second would be to bootstrap from the JavaScript, like so, after having creating your app through  angular.module("myApp", []):  angular.bootstrap(document, ['myApp']);
  • 20. Automatic initialization  Angular initializes automatically upon DOMContentLoaded event or when the angular.js script is evaluated if at that time document.readyState is set to 'complete'. At this point Angular looks for the ng-app directive which designates your application root. If the ng-app directive is found then Angular will: I. load the module associated with the directive. II. create the application injector III. compile the DOM treating the ng-app directive as the root of the compilation. This allows you to tell it to treat only a portion of the DOM as an Angular application. IV. <!doctype html> V. <html ng-app="optionalModuleName"> VI. <body> VII. I can add: {{ 1+2 }}. VIII. <script src="angular.js"></script> IX. </body>
  • 21. Manual Initialization If you need to have more control over the initialization process, you can use a manual bootstrapping method instead. Examples of when you'd need to do this include using script loaders or the need to perform an operation before Angular compiles a page.  <!doctype html>  <html> <body>  Hello {{'World'}}!  <script src="http://code.angularjs.org/snapshot/angular.js"></script>  <script>  angular.module('myApp', [])  .controller('MyController', ['$scope', function ($scope) {  $scope.greetMe = 'World';  }]);  angular.element(document).ready(function() {  angular.bootstrap(document, ['myApp']);  }); You should not use the ng-app directive when manually bootstrapping your app.
  • 22. Data Binding Data-binding in Angular apps is the automatic synchronization of data between the model and view components. The view is a projection of the model at all times. When the model changes, the view reflects the change, and vice versa. First the template (which is the uncompiled HTML along with any additional markup or directives) is compiled on the browser.  The compilation step produces a live view. Any changes to the view are immediately reflected in the model, and any changes in the model are propagated to the view.  The model is the single-source-of-truth for the application state, greatly simplifying the programming model for the developer.  You can think of the view as simply an instant projection of your model.  the controller is completely separated from the view and unaware of it.  This makes testing a snap because it is easy to test your controller in isolation without the view and the related DOM/browser dependency.
  • 23. Data binding 2-way databinding vs 1-way databinding.
  • 24. CSS classes used by Angular Ng-scope: Usage: angular applies this class to any element for which a new scope is defined. Ng-binding: Usage: angular applies this class to any element that is attached to a data binding, via ng-bind or {{}} curly braces ng-invalid, ng-valid: Usage: angular applies this class to an input widget element if that element's input does not pass validation. ng-pristine, ng-dirty: Usage: angular input directive applies ng-pristine class to a new input widget element which did not have user interaction. Once the user interacts with the input widget the class is changed to ng-dirty.
  • 25. Forms . A Form is a collection of controls for the purpose of grouping related controls together. Form and controls provide validation services, so that the user can be notified of invalid input. This provides a better user experience, because the user gets instant feedback on how to correct the error. A form is an instance of FormController. The form instance can optionally be published into the scope using the name attribute. Similarly, an input control that has the ngModel directive holds an instance of NgModelController. Such a control instance can be published as a property of the form instance using the name attribute on the input control. The name attribute specifies the name of the property on the form instance. This implies that the internal state of both the form and the control is available for binding in the view using the standard binding primitives.
  • 26.
  • 27. Custom triggers By default, any change to the content will trigger a model update and form validation. You can override this behavior using the ngModelOptions directive to bind only to specified list of events. I.e. ng-model-options="{ updateOn: 'blur' }" will update and validate only after the control loses focus. Example: //Changes on the inputs within the form will update the model only// Index.html <div ng-controller="ExampleController"> <form> Name: <input type="text" ng-model="user.name" ng-model-options="{ updateOn: 'blur' }" /><br /> Other data: <input type="text" ng-model="user.data" /><br /> </form> <pre>username = "{{user.name}}"</pre> </div> Script.js angular.module('customTriggerExample', []) .controller('ExampleController', ['$scope', function($scope) { $scope.user = {}; }]);
  • 28. Custom Validation  Angular provides basic implementation for most common html5 input types: (text, number, url, email, radio, checkbox), as well as some directives for validation (required, pattern, minlength, maxlength, min, max).  Defining your own validator can be done by defining your own directive which adds a custom validation function to the ngModel controller. To get a hold of the controller the directive specifies a dependency  Validation occurs in 2 places  Model to View update - Whenever the bound model changes, all functions in NgModelController#$formatters array are pipe-lined, so that each of these functions has an opportunity to format the value and change validity state of the form control through NgModelController#$setValidity  View to Model update - In a similar way, whenever a user interacts with a control it calls NgModelController#$setViewValue. This in turn pipelines all functions in the NgModelController#$parsers array, so that each of these functions has an opportunity to convert the value and change validity state of the form control through NgModelController#$setValidity.
  • 29. Implementing custom form controls (using ngModel)  Angular implements all of the basic HTML form controls (input, select, textarea), which should be sufficient for most cases. However, if you need more flexibility, you can write your own form control as a directive.  In order for custom control to work with ngModel and to achieve two-way data-binding it needs to:  implement $render method, which is responsible for rendering the data after it passed the NgModelController#$formatters,  call $setViewValue method, whenever the user interacts with the control and model needs to be updated. This is usually done inside a DOM Event listener.  Eg:  <div contentEditable="true" ng-model="content" title="Click to edit">Some</div>
  • 30. FILTERS A filter formats the value of an expression for display to the user. They can be used in view templates, controllers or services and it is easy to define your own FILTER. Using filters in view templates Filters can be applied to expressions in view templates using the following syntax: {{ expression | filter }} CHAINING FILTERS : {{ expression | filter1 | filter2 | ... }} FILTERS WITH ARGUMENTS: {{ expression | filter:argument1:argument2:... }}
  • 31. filters in controllers, services, and directives. For this, inject a dependency with the name <filterName>Filter T.o your controller/service/directive. E.g. using the dependency numberFilter will inject the number filter. The injected argument is a function that takes the value to format as first argument and filter parameters starting with the second argument. EXAMPLE INDEX.HTML <div ng-controller="FilterController as ctrl"> <div> All entries: <span ng-repeat="entry in ctrl.array">{{entry.name}} </span> </div> <div> Entries that contain an "a": <span ng-repeat="entry in ctrl.filteredArray">{{entry.name}} </span> </div> </div> SCRIPT.JS angular.module('FilterInControllerModule', []). controller('FilterController', ['filterFilter', function(filterFilter) { this.array = [ {name: 'Tobias'}, {name: 'Jeff'}, {name: 'Brian'}, {name: 'Igor'}, {name: 'James'}, {name: 'Brad'} ]; this.filteredArray = filterFilter(this.array, 'a'); }]); All entries: Tobias Jeff Brian Igor James Brad