Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Custom Validation

Answer»

Custom Validation
In ANGULARJS we have power to create our own validation function . It is little bit tricky. We need to add a new directive to our application. And to deal with the validation in function we need to do a certain specified arguments.
In below example we have created our own directive and we name this is my-directive. Here we will check if input field has a character in it if it is there then we will get "True" ELSE it is "False".


AngularJS Custom Validation
In Above example below are the most usefull points which helps you to understand the example:-

(1)In new directive will be referred to by using the attribute my-directive.

(2)Here in the JavaScript we START adding a new directive named as myDirective.

(3)Name should be choosen safely LIKE camel case name myDirective. But when invoking this we must use "-" separated name as my-directive.

(4)When retrun object where we specify that we require ngModel which is the ngModelController.

(5)We Make a linking function which takes arguments and the fourth argument, mCtrl, is the ngModelController.

(6)We specify a function, and is named myValidation, which takes one argument, this argument is the value of the input element.

(7)Test if the value contains the letter "a", and set the validity of the model controller to either true or false.

(8)At last, mCtrl.$parsers.push(myValidation); will add the myValidation function to an array of other functions, which will be executed EVERY time the input value changes.

2.

AngularJS Events

Answer»

AngularJS Events
Most of the important chapter here is AngularJS Events. AngularJS has its own HTML event directives. We can add AngularJS event listeners to our HTML elements by using below 17 odd directives.

(1)ng-blur
(2)ng-change
(3)ng-click
(4)ng-copy
(5)ng-cut
(6)ng-dblclick
(7)ng-focus
(8)ng-keydown
(9)ng-keypress
(10)ng-keyup
(11)ng-mousedown
(12)ng-mouseenter
(13)ng-mouseleave
(14)ng-mousemove
(15)ng-mouseover
(16)ng-mouseup
(17)ng-paste

And above event directive help us RUN angularJS function at certain user events.

And AngularJS event will not overright the HTML event and both events gor fires.

In above Directive we have many Mouse Events as given below

(1)ng-mouseover
(2)ng-mouseenter
(3)ng-mousemove
(4)ng-mouseleave

and 3 click events of mouse

(1)ng-mousedown
(2)ng-mouseup
(3)ng-click

We can add mouse events on any HTML element. Below example will help to understand the mouse events. Here i have use event mousemove which will count the movement of mouse:-


AngularJS Mousemove

The ng-click Directive


This ng-click directive defines AngularJS code that will execute on element is being clicked.


AngularJS Mouse Click

Example No 2 for ng-click





AngularJS Mouse Click2

Toggling True and False


If we want to show a section of HTML code hide or show when we click on button. Same we do on dropdown MENU and make the button behave like toggle switch:-


AngularJS Toggle HideShow
In above figure showtopic variable starts out as the boolean value as false. With

myFunc function sets the showtopic variable to opposite of what it is by using the

not operator.

$event Object


We can also PASS $event object as an argument when we CALL the function.The $event object CONTAINS the browser event object. Below example will be more clear to you:-

AngularJS Coordinates
3.

AngularJS $http

Answer»

AngularJS $http
We use $http as a SERVICE to read data from remote servers. From AngularJS $http we make a request to the server and returns a response. Below is the example of $http request response model.


AngularJS Http Service
METHODS
In above example we uses the .get METHOD of $http service. And .get method is a

shortcut method of $http service. Below are the example of different shortcut methods
(i).delete()
(ii).get()
(iii).head()
(iv).JSONP()
(v).patch()
(vi).post()
(vii).put()
Above all methods are shortcuts of calling the $http service.

AngularJS Http Method
In above example it EXECUTE the $http service with an object as an argument. And object is specifying the HTTP method , URL and sucess and failure operation details.

Properties
The response we get from server is an object with these below properties:
(1).config:- the object used to generate the request.
(2).data:- it could be a string, or an object, carrying the response from the server.
(3).headers:- a function to use to get header information.
(4).status:- a number defining the HTTP status.
(5).statusText:- a string defining the HTTP status.
Below example will helps you get response with above properties.



AngularJS Http Properties
To handle this errors we will add one more functions to the .then method


AngularJS Http Then

4.

AngularJS API

Answer»

AngularJS API
As we KNOWS that API stand for Application Programming Interface. Now we read something about AngularJS Global API. We use AngularJS Global API to perform common tasks like we do with global JavaScript FUNCTIONS as given below:-

(1)Comparing Objects
(2)Iterating Objects
(3)Converting Data

We can access Global API functions by using angular object. Below are the list of some common API functions:-

(1)angular.lowercase():- Here we will convert string into lowercase
(2)angular.uppercase():- Here we will convert string into uppercase
(3)angular.isString():- This will return true if the reference is string
(4)angular.isNumber():- this will return true if the reference is a number

Below we use 4 above API Function:-

(1)angular.lowercase()


var app = angular.module('myTestApp', []);
app.controller('myTestCtrl', function($SCOPE) {
$scope.x1 = "ADAM SUTRO";
$scope.x2 = angular.lowercase($scope.x1);
});



(2)angular.uppercase()


var app = angular.module('myTestApp', []);
app.controller('myTestCtrl', function($scope) {
$scope.x1 = "adam sutro";
$scope.x2 = angular.uppercase($scope.x1);
});


(3)angular.isString()


var app = angular.module('myTestApp', []);
app.controller('myTestCtrl', function($scope) {
$scope.x1 = "ADAM SUTRO";
$scope.x2 = angular.isString($scope.x1);
});


(4)angular.isNumber()


var app = angular.module('myTestApp', []);
app.controller('myTestCtrl', function($scope) {
$scope.x1 = "ADAM";
$scope.x2 = angular.isNumber($scope.x1);
});
5.

AngularJS HTML DOM

Answer»

AngularJS HTML DOM
AngularJS has number of directives that are used to binding application data to attributes of HTML DOM elements. Below are the different DIRECTIVE which are used for binding application data.

The ng-disabled Directive


We use ng-disabled directive to binds AngularJS application data to disabled attributes of HTML elements. Below is the example which helps you understand ng-disabled directive:-


AngularJS ng-disabled
Below are the 3 point for above images
(1)As in above figure ng-disabled directive binds the application data myTestSwitch to the HTML BUTTON disabled attribute.
(2)And ng-model directive binds the value of HTML checkbox element to the value of myTestSwitch.
(3)If values of myTestSwitch evalutes to true the button will be disabled.

The ng-show Directive


We use this ng directive to either SHOWS or hides an HTML elements. Below example will helps you to under that:-


AngularJS ng-show
In above image we will use ng-show to DISPLAY some value by putting as "true" then it is visible if you PUT as "false" it will hide the values

The ng-hide Directive


As we use ng-show in similar way we will use ng-hide directive to hide some values


AngularJS ng-hide
6.

AngularJS Database

Answer»

AngularJS Database
As we know ANgularJS is perfect to display data and it should also be from database like SQL,MySQl or another source but data should be in JSON format. Below i have provide some example to fetch data from different data source.

Here first example is fetch data from PHP SERVER which have MySQL data


AngularJS Php Files
ASP.NET with .aspx Page


AngularJS ASP.net Files
I have provide connectivity with below 4 pages
(1)Using PHP and MySQL. RETURNING JSON.
(2)Using PHP and MS Access. Returning JSON.
(3)Using ASP.NET, VB, and MS Access. Returning JSON.
(4)Using ASP.NET, RAZOR, and SQL Lite. Returning JSON.

Now we try Cross-Site HTTP REQUESTS here with some examples. When a request for data from diferent server is happen which is other than the requesting page that is called Cross-site http requests. Cross-site are very common in web and most of the sites are using this. Let suppose generaly we USE pages load CSS, images and scripts from different servers.
But in modern web cross-site http request from scripts are restricted to same site for some security issues. Below is the line which is used when we added to allow cross-site access.

header("Access-Control-Allow-Origin: *");

Below is the example to fetch records from MySQL with PHP

(1)Server code for PHP and MySQL


AngularJS PHP MySQL
(2)Server code PHP with MS Access

AngularJS PHP MsAccess
(3)Server Code for vb.net with MSAccess (ASP.NET)


AngularJS asp.net MsAccess
(4)Server Code for Razor C# and SQL Lite

AngularJS Razor SQl Lite

7.

Validation Example

Answer»

Validation Example
In below example we have used model object with two properties (1)User and (2)Email. And ng-model binds the INPUT elements to the model. And SPAN color is CHANGE if value is $dirty or $INVALID for email. And we use directive ng-show here


AngularJS Custom Validate 2

8.

Validation CSS

Answer»

Validation CSS
AngularJS helps to add CSS classes to forms and input fields depending on there states. Below are the classes are added to or removed from input fields. Below are the list of different states as given belows:-
(1)ng-untouched When field has not been touched YET
(2)ng-touched When field has been touched
(3)ng-pristine When field has not been MODIFIED yet
(4)ng-dirty When field has been modified
(5)ng-valid when field content is valid
(6)ng-invalid When field content is not valid
(7)ng-valid-key key for each validation. Example: ng-valid-required, useful when there are more than one thing that must be validated
(8)ng-invalid-key when ng-invalid-required is required

Below are different classes are added or removed from forms:-
(1)ng-pristine When No fields has not been modified yet
(2)ng-dirty When One or more fields has been modified
(3)ng-valid When form content is valid
(4)ng-invalid When form content is not valid
(5)ng-valid-key One key for each validation. Example: ng-valid-required, useful when there are more than one thing that must be validated
(6)ng-invalid-key Example: ng-invalid-required

Classes are removed if value they represent is false.

Below is the example to use CSS on input textbox with example:-


ANgularJS Validation CSS
Below is one more example which is form based:-

ANgularJS Validation CSS2

9.

Select Option 2

Answer» SELECT Option 2
In previous chapter we have learn bind dropdown list with array. Now we WOULD TRY binding dropdown list with object. Below is the example of object with key-value pairs:-

$scope.Employees = {
Emp01 : "Adam",
Emp02 : "TIM",
Emp03 : "John"
};

The expression in ng-options is littlebit different for objects.

In below example we have taken an object which have values in key-value like x present as the key and y present as the value.


AngularJS Object Select
One more example where in object we have 3 values as given in below object and

example

$scope.EMployees = {
Emp01 : {EmpName : "Adam", Department : "IT", Skill : "MCA"},
Emp02 : {EmpName : "Tim", Department : "Admin", Skill : "MBA"},
Emp03 : {EmpName : "Bob", Department : "HR", Skill : "MBA"}
};


AngularJS Object Select3
10.

Form Validation

Answer»

Form Validation
From AngularJS we can validate input data by user. Its offers client SIDE form validation. From AngularJS monitors state of form and input fields like input, textarea and select. And helps you to get the current state to the user. From AngularJS will holds information about if they have been touched or modified or not. We can USE standard HTML5 attributes to validate user input. We can ALSO make custimzation validation.

As we all know the only client side validation is not enough to fully secure user input we will also need server side validation.

Now below have some validation with examples:-

Required Field


Here we will use HTML5 attribute required to specify that input field must have some values. As below example:-


AngularJS Required Field

E-mail


Here we use HTML5 type email to specify that the value must be an email. And below is the example:-

AngularJS Email Validation
Now we read most important aspects in form state and input state

Form State and Input State



AngularJS constantly update the state of both the form and Input fields.

Below are different Input fields have the following states:-
(1)$untouched This will happen when field has not been touched yet
(2)$touched This will happen when field has been touched
(3)$PRISTINE This will happen when field has not been modified yet
(4)$dirty This will happen when field has been modified
(5)$invalid This will happen when field content is not valid
(6)$valid This will happen when field content is valid

All of above properties of input field EITHER true or false.

Below are different Forms states:-
(1)$pristine When No fields have been modified yet
(2)$dirty when One or more have been modified
(3)$invalid When form content is not valid
(4)$valid when form content is valid
(5)$submitted when form is submitted

All of above properties either true or false.

From above properties we have use one touched example which will helps you to understand


AngularJS Validation Touched
11.

AngularJS Forms

Answer»

AngularJS Forms
Within the forms in AngularJS will PROVIDES some very SILENT fatures like data-binding and vaildations of input controls.Below are the list of input controls

Input Controls


Below are THR HTML input elements:-
(1)input elements
(2)select elements
(3)button elements
(4)textarea elements

with the help ng-model directive we will bind input controls which provides data-binding. Below is the example which helps you to understand the data-binding. In below example we will understand that application have a property named employeename. And in below example ng-model directive binds the input CONTROLLER to the rest of our application. And in below example the property employeename can be referred to in a controller:-


AngularJS Forms

And in another example we can also referred to another place of application:-



AngularJS Forms2

Checkbox


As we knows the checkbox has the two values either true or false. If check box is checked then it is true we use this value in our application to display some values by using ng-show directives.


AngularJS Forms checkbox

Radiobuttons


In below example we will bind radio button to our application with ng-model directive with 3 values. And same ng-model have different values and we will display only the selected one.


AngularJS Radio Button
In Above example myTestVar will be either ASP.NET,Java or AngularJS.

Selectbox


In below example we will bind select boxes to our application with the ng-model directive. And property define ng-model attribute will have the value of selected option from select box. Below selectbox we have 3 values


AngularJS Select option
In above example value of myTestVar will either be asp.net,java or angularJS

One More Example


In below example we have tried some value on input box and have below facts
(i)ng-app directive defines the AngularJS application.
(ii)ng-controller directive defines the application controller.
(iii)ng-model directive binds 2input elements to the user object in the model.
(iv)myTestCtrl controller sets initial values to master object and we define reset() method.
(v)reset() methods sets the user object EQUAL to the master object.
(vi)ng-click directive invokes the reset() method when button is clicked.




AngularJS Application Exam
12.

Select Option

Answer»

Select Option
AngularJS helps to create dropdown lists based on items from an array or from any of object. By USING NG directive we can bind select box. And that ng directive is ng-options which helps you to create dropdownlist. Below is the example which will helps you to create that dropdownlist.


AngualrJS Select Options
Other option
We can also use other directive in place of ng-options that is ng-repeat directive. Because ng-repeat directive REPEATS a BLOCK of HTML code for each item available in array so it can be USED to create options in dropdowlist. But ng-options directive is specially for filling a dropdown list with options.



Example:-2
AngualrJS ng-Repeat


Example with double array
AngualrJS Ng option

AngualrJS Dropdown option

13.

AngularJS Tables

Answer»

AngularJS Tables
In AngularJS we USE ng DIRECTIVE to display tables and name of directive is ng-repeat. And displaying tables with angular is very simple below is the example of displaying table with USING $http remove server files.

AngularJS Tables
Using CSS with Tables
We can ALSO apply CSS on AngularJS Tables or we can say on ng-repeat. Below is the example to do that.

AngularJS CSS Tables
Using Filter orderBy
We can sort table order by using orderBy filter. Below is the example for sorting a table with some filter apply on this.


AngularJS Tables orderBy
uppercase Filter
Here we will srite code to convert some COLOUMN to uppercase. Below is the example.


AngularJS Tables Uppercase
Applying Table Index by Using $index
Here we will display the table index by using $index and put that in increment by +1

AngularJS Tables index
Using $even and $odd
By using $even and $odd condition we can apply soem filter on that

AngularJS Tables odd even

14.

Model Directive

Answer»

Model Directive
As we know that ng-model directive bind the value of HTML controls LIKE input, select and textarea to the APPLICATION DATA. With the help of ng-model directive we can bind the value of an input field to a variable created in AngularJS. Below is the example for single way binding with AngularJS:-


AngularJS Model
Two-Way Binding:-In this binding it will GOES in both ways. If user will change the value inside the input field. AngularJS property will change its values.Below is the example for two way binding:-

AngularJS Two way binding

15.

Add a Directive

Answer»

Add a Directive
AngularJS has MANY built-in directives. We can USE this to add some FUNCTIONALITY in out APPLICATIONS. We can use MODULE to add our own directives in our applications.

Below is the example for adding a directive


AngularJS Add Directive

16.

Controller Basic

Answer»

Controller Basic
Now we will work on controller that how to add Controller in application by USING ng-controller directive.

Below is the example for Controller in AngularJS


AngularJs Controller Basic
In Above example we have USED both MODULE and controller and controller cannot be define without the module

17.

Validate Inputs

Answer» VALIDATE Inputs
In ng-model we can also input some validation for APPLICATION DATA and this may have validation like Number, e-mail or required type. Below example will helps you to understand where we will put validation



AngularJS Validation
the span will be DISPLAYED only if the expression in the ng-show attribute returns TRUE.
18.

Data Binding

Answer»

Data Binding
In angularJS data binding is the synchronization between the Model

and the View. In most of the cases in AngularJS applications have a

data model. Data Model is COLLECTION of data AVAILABLE for the

application.

HTML View
HTML container where we display the AngularJS application is called view. ANd this view has access to the model. And we have some more option to displaying model data in the view. We can use ng-bind directive which help us to bind the innerHTML of the element to the specified model property. We can use ng-model directive on HTML CONTROLS to bind the model to the view.

Two-way Binding
As we knows that AngularJS is the SYNC between model and view. When data in model changes the view reflects the changes. And when data in view changes the model is also updated as well. This happen very quick time and automatically. And this will make sure that model and the view is updated at all times.

19.

AngularJS Filters

Answer»

AngularJS Filters
As we knows in another language filter is USED to format data same as this done in AngularJS. Filter can be added in AngularJS to format data. Below are the different AngularJS Filters:-

(1)currency:-From this we will format number to a currency format.
(2)date:-From this we will format a date to a specific format.
(3)filter:-From this we will select a subset of items from an array.
(4)json:-From this we will format and object to JSON STRING.
(5)limitTo:-From this we will LIMITS an array/string into a specified number of elements and charcaters.
(6)LOWERCASE:-From this we will format a string to lower case.
(7)number:-From this we will format a number to a string.
(8)orderBy:-From this we will do orders an array by an expression.
(9)upppercase:-From this we will format a string to upper case.

Below is the example for converting string to uppercase and lowercase


Angular Filters
Adding Filters to Directives
We can also add Filters to directives like ng-repeat and to USE that we will use "|" pipe character to apply filter.

Angular Filters Array

Currency Filter


Angular Currency Filter
The filter Filter
filter filter select a subset of an array. The filter filter can only be used on arrays and then returns array containing only the matching characters or items.


Angular filters to filters

20.

Root of Scope

Answer»

Root of Scope
All of application have a $rootScope which is scope created on the HTML element that have ng-app DIRECTIVE. And this rootScope is available in entire application.
If the VARIABLE name is same in both current scope and rootScope then applications uses the ONE which is current scope.

Here in below example we have used a variable "color" which is EXIST in both controller scope and in rootScope.


ANgularJS Multi

21.

AngularJS Scope

Answer»

AngularJS Scope
Scope is BINDING part between the View(HTML) and the Controller (JavaScript).
Scope is OBJECT with the AVAILABLE properties and methods.
Scope is always available for both the view and controller.

USE of Scope?
When we make controller in ANgularJS we will pass the $scope object as an argument. Below example will helps you to undersatnd the properties made in controller and can be referred in the view:-

AngularJS Scope
In above screen we add properties to the $scope object in the controller, and the view gets access to these properties. In the view we cannot use the prefix $scope.

Uses Of Scope?
IF below 3 points comes in AngularJS application then scope comes into picture:-
(1)View which is the HTML
(2)Model which is the data available for the current view
(3)Controller which is the JavaScript FUNCTION that changes, makes removes and controls the data
If above 3 points comes into picture then scope is the model.
Here scope is a JavaScript object with properties and methods which is available for both the view and the controller.


AngularJS Scope Uses

22.

AngularJS Controller

Answer»

AngularJS Controller
As we knows now that Applications in AngularJS are controlled by the controllers. As we also know there is immediate synchronization between the Model and the View. And controller can be COMPLETELY separated from the view and will concentrate on Model data. And with the data binding in AngularJS the view will reflect CHANGES made in controller. AngularJS controllers control the data of AngularJS applications.


AngularJS Controller
AngularJS controllers are regular JavaScript Objects. The ng-controller directive defines the application controller. And controller is JavaScript object which is created by STANDARD JavaScript object constructor.


AngularJS JavaScript Controller
Now i will give some details on the above example. AngularJS

application is defined by ng-app="myTestApp". And the application run inside the < div> TAG. And the ng-controller="myTestCtrl" attribute is and AngularJS directive which defines the controller.

And myTestCtrl function is a JavaScript function.

And AngularJs will invoke the controller witha $scope object.

In AngularJS $scope is application object which is owner of application variable and function.

Controller creates 2 properties in scope and these are EmployeeFirstName and EmployeeLastName.

And ng-model DIRECTIVES bind input fields to the controller properties.

23.

CSS Classes

Answer» CSS CLASSES
We can also apply some validation on CSS class here we will LEARN validation name "required" through that we will apply some validation on input control.


AngularJS CSS Validation
The ng-model directive adds orremoves the following classes, according to the status of the form field:
(i) ng-empty
(ii) ng-not-empty
(iii)ng-touched
(iv) ng-untouched
(v) ng-valid
(vi) ng-invalid
(vii)ng-dirty
(VIII)ng-pending
(IX) ng-pristine
24.

AngularJS Modules

Answer» ANGULARJS MODULES
Here we will KNOW what is AngularJS Modules and why we use and how we will use this. An AngularJS modules defines and application. There are many parts which are contains in module in application. Module also contains the application controllers. And Controllers always belong to a module.

To create a module we use AngularJS function which is angular.module

Now below example will define how to create a Module


AngularJS Module
In above "myApp" parameter refers to an HTML element in which application will run.

We can add Controllers, DIRECTIVES, filters and many more in AngularJS application.
25.

AngularJS JSON

Answer»

AngularJS JSON
Data we GET from service response is expected to be in JSON format. As JSON is a great way of transporting data and its quite easy to use them in AngularJS and as well as in JavaScript. We take a database example which have 7 records in JSON formats likes below.


JSON data
And all of data is wrapped in array which is called records.

AngularJS JSON data
Above example have below details which will clarify you the details USED in above example
(1)Above application defines myTestCtrl controller with a $scope and $http OBJECT.
(2)$http is an XMLHttpRequest object for requesting external data.
(3)$http.get() reads JSON data from Employees.php as DEFINE above
(4)And on sucess controller will create myTestData in scope with JSON data from the server.

26.

Angular CSS Properties

Answer» ANGULAR CSS Properties
Here we have produce one example to update or handle CSS properties through AngularJS. Here we have USE ng-init directive to initalize some values as GIVEN below example.

Here we have take a example to change the COLUR of textbox through the code of AngularJS



AngularJS CSS Properties
27.

AngularJS Expressions 2

Answer»

AngularJS Expressions 2
As from previoud chapter we knows that with the help of AngularJS we will bind data to HTML by using Expressions. There are below some of the most importants fact or we can say most important features are given below.

First POINT is that AngularJS expression can be written in between the DOUBLE braces if we not use ng-bind directives. Syntax is given below
Syntax
{{ expression }}

Second point is that if we use ng-bind directive then we need to use below syntax
Syntax
ng-bind="expression"

Third point is that result return by AngularJS expression is on same location where it is define.

Fourth point for AngularJS expression is that it is that it will contain Literals, operators and VARIABLE as same as we use for JavaScript. And there are 2 examples are given below.
Syntax
Example1:- {{ 5+3 }}
Example2:- {{ FirstName +" " +LastName }}


AngularJS Expression
One point in above example is that we have use ng-app directive as blank but if we will remove the ng-app directive then it will not resolve the expression and display this without solving this



AngularJS Without ng-app

28.

Angular init Directive

Answer»

Angular init Directive
As from last 2 chapters we got that AngularJS directives are HTML attributes with an ng prefix. Now comes to ng-init directive it is used to initialies AngularJS APPLICATION variables. As per the given below images:-



AngularJS Init

We can also USE some alternative for ng-init as given in below image


AngularJS Data Init
We can use data-ng-, instead of ng-, if you want to MAKE your PAGE HTML VALID.

29.

AngularJS Introduction

Answer»

AngularJS Introduction
Here in this chapter we will get AngularJS history and its Introduction with some very good examples.

AngularJS History
One of the FIRST version of AngularJS 1.0 was released in year 2012. One of google employee has start work on AngularJS in year 2009. And after the sucess of this google has officially supported this.

AngularJS basic Introduction
We can say that AngularJS is a JavaScript framework. We can add that in HTML page with a < script> Tag. As we mention in LAST chapter 1 we have mention that AngularJS extends HTML attributes with Directives and then we can binds data to HTML with the help of Expressions. AngularJS is written in JavaScript. It is ditributed as javascript file so we will add this to WEB page in script tag as given below:-


AngularJS Framework Tag

Extends HTML
With the help of ng-directives AngularJS extends HTML below are some

examples:-
(i)ng-app:- This will defines an AngularJS applications.
(ii)ng-model:- This will helps in BINDING the value of HTML controls to application data and these controls are input, select, textarea etc.
(III)ng-bind:-This will binds application data to HTML view.

Now below example will define defination for above 3 ng-directives


ng-directive angular

Now will explain the above 3 ng-directive why we use and its details:-

In above example ng-app directive will tells angularJS that the above < div> element is the owner of AngularJS application.
In above we use ng-model directive that binds the value of input field to application variable name.
In above we use ng-bind directive to binds the content of < p> element to the application variable name.

30.

Numbers And Strings

Answer»

Numbers And Strings
Here we have handle the numbers in AngularJS. As in previous chapter we knows that Number handling is same as we DONE in JavaScript numbers.

Below i have mentioned 2 EXAMPLES one is with ng-bind directive and 1 is WITHOUT ng-bind directive.

Syntax of AngularJS Number Example1


AngularJS Numbers
Syntax of AngularJS Number EXAMPLE2 with ng-bind


AngularJS Numbers2

As we handle the numbers in JavaScript same we done with strings in JavaScript. Below are 2 example for this 1 is with ng-bind and 1 is without ng-bind.

Syntax of AngularJS String Example1


AngularJS String

Syntax of AngularJS String Example2 with ng-bind


AngularJS String2

31.

Objects And Array

Answer» OBJECTS And Array
Both the Objects and Array are HANDLE in same as we will DONE in JavaScript. Below i have given 4 example 2 is for Objects and 2 is for Arrays. In both of these we use ng-init directives.

Syntax of ANGULARJS Objects


AngularJS Objects

Syntax of AngularJS Objects with ng-bind


AngularJS Objects2

Syntax of AngularJS Arrays


AngularJS Array

Syntax of AngularJS Arrays with ng-bind

AngularJS Array2
32.

AngularJS VS JavaScript

Answer»

AngularJS VS JAVASCRIPT
As from previous 9 chapter we knows that there are many points on which both JavaScript and AngularJS are similar. Below are some most important facts about both of this:-

(1)Both in JavaScript and AngularJS EXPRESSIONS both contains Literals, Operators and Variables.

(2)As both JavaScript and Angular expressions are WRITTEN inside HTML.

(3)AngularJS expressions will not support Loops, exceptions and conditionals while JavaScript expression will do all of this.

(4)AngularJS expressions support FILTERS but JavaScript expression will not do this.

33.

Controllers in Files

Answer»

Controllers in FILES
As from previous CHAPTER we should know that controllers will be done with module we cannot define controllers WITHOUT Modules. We have a option here that we can PUT module and the controllers in JAVASCRIPTS files.

In below example i have put module definition in "MyFirstApp.js" javascript file and Controllers in "MyFirstCtrl.js" JavaScript files.


Controller in Files
In Above Example we have 2 .JS Files

(1) Our First File myFirstApp.js
var app = angular.module("myFirstApp", []);


And 2nd files is given below with details
(2) Our Second File myFirstCtrl.js
app.controller("myFirstCtrl", function($scope) {
$scope.EmployeeFirstName = "Adam";
$scope.EmployeelastName= "Sutro";
});

34.

Load the Library

Answer»

Load the Library
There is one theory that Global Functions should not be define in JavaScript because if we define Global function in JavaScript then is should be easily overwritten or destroyed by any other scripts. To overcome this types of issue AngularJS module REDUCES the problem by keeping all functions local to the module.

Now ANOTHER topic which we define here is that when we load the library and where should we place the Script. It is very common in HTML applications to place scripts at the end of < body> elements. And we also recommended you to load the AngularJS library either in the or at the START of tag.

And reason COULD be because CALLS to angular.module can be compiled after the library has been loaded.


AngularJS Declartion

35.

AngularJS Tutorial

Answer»

AngularJS Tutorial
After AngularJS it will extends the HTML and extends the FEATURES with new attributes.
For Single Page Applications (SPA) AngularJS is perfect option.
AngularJS is very easy to Learn.

Now you Learning is starts from Here and will cover Angular in 3-4 days with

some some very good examples.

This tutorial helps you to learn AngularJS very quickly and efficiently.

First of all we learn the BASICS of AngularJS:-
(1)Directives
(2)Expressions
(3)Filters
(4)Modules
(5)COntrollers

Then You will get the other topics for AngularJS:-
(1)Events
(2)DOM
(3)FORMS
(4)Input
(5)Validation
(6)Http etc.

Before start study about Angular you MUST have some basic understanding of

below 3 things:-
(1)HTML
(2)CSS
(3)JavaScript

Now below IMAGE is the First example of AngularJS



Angular First Program

36.

AngularJS Applications

Answer»

AngularJS Applications
Now we will provide a example which will have 2 thing in it that is modules and controllers. And whta is these 2 things. AngularJS modules define the AngularJS applications. And the 2nd thing that is controllers. AngularJS controllers CONTROL AngularJS applications. We will use ng-app directive which will define the APPLICATION and ng-controller directive will DEFINES the controller.

Now below example will let you KNOW the both 2 things with its definition and using



AngularJS Application

In above example AngularJS modules define applications.

And AngularJS controller control applictions.

output


AngularJS Application Output

37.

AngularJS Expressions 1

Answer»

AngularJS EXPRESSIONS 1
This is the first example of using expressions in AngularJS. We need to USE DOUBLE braces for Regular Expressions

SYNTAX
{{ expression }}

and above syntax will provide "output" data same location where expression is define:-

Now we have example which will let you understand the AngularJS expressions:-


AngularJS Expression 1

AngularJS expression will do the same as we did with ng-bind directive. And i have given the below example which will helps you to get the example of binding without ng-bind



AngularJS Expression 2

In above example i have use the ng-model variable but not used ng-bind that i have done with the help of expression.