Unit V
Unit V
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js
"></script>
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.
ANGULAR JS EXAMPLE:
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/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>
OUTPUT:
Input something in the input box:
Name:
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 content of the <p> element to the application
variable name.
ANGULARJS APPLICATIONS
It is mainly used for creating single web page application.
CCS375 - WEB TECHNOLOGIES PIT / CSE
What is MVC?
The Model-View-Controller (MVC) framework is an architectural/design
pattern that separates an application into three main logical
components Model, View, and Controller. Each architectural component is
built to handle specific development aspects of an application.
It isolates the business logic and presentation layer from each other. It was
traditionally used for desktop graphical user interfaces (GUIs).
Nowadays, MVC is one of the most frequently used industry-standard web
development frameworks to create scalable and extensible projects.
It is also used for designing mobile apps.
MVC was created by Trygve Reenskaug.
The main goal of this design pattern was to solve the problem of users
controlling a large and complex data set by splitting a large application into
specific sections that all have their own purpose.
Features of MVC :
It provides a clear separation of business logic, Ul logic, and input
logic.
It offers full control over your HTML and URLs which makes it easy
to design web application architecture.
It is a powerful URL-mapping component using which we can build
applications that have comprehensible and searchable URLs.
It supports Test Driven Development (TDD).
CCS375 - WEB TECHNOLOGIES PIT / CSE
Components of MVC :
The MVC framework includes the following 3 components:
Controller
Model
View
Controller:
The controller is the component that enables the interconnection between the
views and the model so it acts as an intermediary. The controller doesn‟t have
to worry about handling data logic, it just tells the model what to do. It
processes all the business logic and incoming requests, manipulates data using
the Model component, and interact with the View to render the final output.
CCS375 - WEB TECHNOLOGIES PIT / CSE
View:
The View component is used for all the UI logic of the application. It
generates a user interface for the user. Views are created by the data which is
collected by the model component but these data aren‟t taken directly but
through the controller. It only interacts with the controller.
CCS375 - WEB TECHNOLOGIES PIT / CSE
Model:
The Model component corresponds to all the data-related logic that the user
works with. This can represent either the data that is being transferred between
the View and Controller components or any other business logic-related data.
It can add or retrieve data from the database. It responds to the controller‟s
request because the controller can‟t interact with the database by itself. The
model interacts with the database and gives the required data back to the
controller.
The model would query the database for the list of all students and then return
that list back to the controller. If the response back from the model was
successful, then the controller would ask the view associated with students to
return a presentation of the list of students. This view would take the list of
students from the controller and render the list into HTML that can be used by
the browser.
The controller would then take that presentation and returns it back to the user.
Thus ending the request. If earlier the model returned an error, the controller
would handle that error by asking the view that handles errors to render a
presentation for that particular error. That error presentation would then be
returned to the user instead of the student list presentation.
As we can see from the above example, the model handles all of the data. The
view handles all of the presentations and the controller just tells the model and
view of what to do. This is the basic architecture and working of the MVC
framework.
Advantages of MVC:
Codes are easy to maintain and they can be extended easily.
The MVC model component can be tested separately.
The components of MVC can be developed simultaneously.
It reduces complexity by dividing an application into three
units. Model, view, and controller.
It supports Test Driven Development (TDD).
It works well for Web apps that are supported by large teams of web
designers and developers.
This architecture helps to test components independently as all
classes and objects are independent of each other
Search Engine Optimization (SEO) Friendly.
Disadvantages of MVC:
It is difficult to read, change, test, and reuse this model
It is not suitable for building small applications.
The inefficiency of data access in view.
The framework navigation can be complex as it introduces new
layers of abstraction which requires users to adapt to the
decomposition criteria of MVC.
Increased complexity and Inefficiency of data
Rails
Zend Framework
Fuel PHP
Laravel
Symphony
MVC is generally used on applications that run on a single graphical
workstation. The division of logical components enables readability and
modularity as well as it makes it more comfortable for the testing part.
UNDERSTANDING NG ATTRIBUTES
AngularJS Directives
AngularJS facilitates you to extend HTML with new attributes. These attributes
are called directives. AngularJS directives are HTML attributes with
an ng prefix.
Directives are special attributes starting with ng- prefix. Following are the most
common directives:
o ng-app: This directive starts an AngularJS Application.
o ng-init: This directive initializes application data.
o ng-model: This directive
o ng-model: This directive defines the model that is variable to be used in
AngularJS.
o ng-repeat: This directive repeats html elements for each item in a
collection.
AngularJS Directives List
AnglarJS directives are used to add functionality to your application. You can
also add your own directives for your applications.
CCS375 - WEB TECHNOLOGIES PIT / CSE
Directive Description
rows.
ng-app directive
ng-app directive defines the root element. It starts an AngularJS Application and
automatically initializes or bootstraps the application when web page containing
AngularJS Application is loaded. It is also used to load various AngularJS
modules in AngularJS Application.
SYNTAX
<div ng-app = ""> ... </div>
EXAMPLE:
<!DOCTYPE html>
<html>
<head>
<title>AngularJS App</title>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></scr
ipt>
</head>
<body>
CCS375 - WEB TECHNOLOGIES PIT / CSE
<!-- The ng-app directive defines the root element of the AngularJS application
-->
<div ng-app="myApp">
<h1>Welcome to my AngularJS App!</h1>
<!-- Other AngularJS directives and content -->
</div>
<script>
// AngularJS module creation
var app = angular.module('myApp', []);
// Define controllers, services, etc., within this module
</script>
</body>
</html>
The HTML file includes the AngularJS library through a script tag.
Inside a <div> with the ng-app="myApp" attribute, you can place
AngularJS content and directives.
This example simply displays a welcoming header within the AngularJS
root element.
The script section defines an AngularJS module named 'myApp' with an
empty dependency array [].
ng-init directive
The ng-init directive evaluates the given expression. This expression can be
used to initialize variables, set up event listeners, or perform other tasks that
need to be done when the application starts.
SYNTAX:
EXAMPLE:
OUTPUT:
Hello World!
The ng-init directive has created an AngularJS variable, which you can use in
the application.
ng-model directive
The ng-model directive is a core Angular directive that binds input, select, and
textarea elements to application data.
It establishes a two-way data binding between the view (HTML) and the model
(TypeScript), ensuring that any changes made to the input field are reflected in
the corresponding data property and vice versa.
In following example, we've defined a model named "name".
CCS375 - WEB TECHNOLOGIES PIT / CSE
SYNTAX:
The syntax for the ng-model directive is as follows:
<input type="text" ng-model="propertyName">
<select ng-model="propertyName">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
</select>
<textarea ng-model="propertyName">Initial Text</textarea>
EXAMPLE:
Consider a component with a property named userName:
TYPESCRIPT
export class MyComponent {
userName: string = '';
}
To bind an input field to this property, use the ng-model directive as follows:
HTML
<input type="text" ng-model="userName">
Any changes made to the input field will be reflected in the userName property,
and any changes to the userName property will be reflected in the input field.
ng-repeat directive
ng-repeat directive repeats html elements for each item in a collection. In
following example, we've iterated over array of countries.
SYNTAX:
<div ng-app="myApp">
<ul>
CCS375 - WEB TECHNOLOGIES PIT / CSE
Example:
<!DOCTYPE html>
<html>
<head>
<title>AngularJS ng-repeat Example</title>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></scr
ipt>
</head>
<body>
<!-- The ng-app directive defines the root element of the AngularJS application
-->
<div ng-app="myApp">
<h2>Fruits List:</h2>
<ul>
<!-- Using ng-repeat to loop through items -->
<li ng-repeat="fruit in fruits">{{ fruit }}</li>
</ul>
</div>
CCS375 - WEB TECHNOLOGIES PIT / CSE
<script>
// AngularJS module creation
var app = angular.module('myApp', []);
The HTML file includes the AngularJS library using a script tag.
Inside the AngularJS root element (ng-app="myApp"), there is an
unordered list (<ul>) containing list items (<li>).
ng-repeat="fruit in fruits" creates a loop that iterates through the fruits
array.
For each item in the fruits array, the {{ fruit }} expression displays the
item's value within an <li> element.
The AngularJS script defines an app module and a controller named
myController.
The controller sets the value of $scope.fruits to an array of fruit names.
<!DOCTYPE html>
<html>
<head>
<title>AngularJS Directives</title>
CCS375 - WEB TECHNOLOGIES PIT / CSE
</head>
<body>
<h1>Sample Application</h1>
<div ng-app = "" ng-init = "countries = [{locale:'en-IND',name:'India'}, {locale:'en-
PAK',name:'Pakistan'}, {locale:'en-AUS',name:'Australia'}]">
<p>Enter your Name: <input type = "text" ng-model = "name"></p>
<p>Hello <span ng-bind = "name"></span>!</p>
<p>List of Countries with locale:</p>
<ol>
<li ng-repeat = "country in countries">
{{ 'Country: ' + country.name + ', Locale: ' + country.locale }}
</li>
</ol>
</div>
<script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"
></script>
</body>
</html>
OUTPUT:
CCS375 - WEB TECHNOLOGIES PIT / CSE
ANGULARJS EXPRESSIONS
In AngularJS, expressions are used to bind application data to HTML.
AngularJS resolves the expression, and return the result exactly where the
expression is written.
Expressions are written inside double braces {{expression}}.They can also be
written inside a directive:
ng-bind="expression".
AnularJS expressions are very similar to JavaScript expressions. They can
contain literals, operators, and variables. For example:
{{ 5 + 5 }} or {{ firstName + " " + lastName }}
AngularJS Expressions Example
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"><
/script>
<body>
<div ng-app>
<p>A simple expression example: {{ 5 + 5 }}</p>
</div>
</body>
</html>
OUTPUT:
Note: If you remove the directive "ng-app", HTML will display the expression
without solving it.
You can also write expressions wherever you want, AngularJS will resolve the
expression and return the result.
CCS375 - WEB TECHNOLOGIES PIT / CSE
AngularJS Numbers
Example:
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"><
/script>
<body>
<div ng-app="" ng-init="quantity=5;cost=5">
<p>Total in dollar: {{ quantity * cost }}</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="" ng-init="quantity=5;cost=5">
<p>Total in dollar: <span ng-bind="quantity * cost"></span></p>
CCS375 - WEB TECHNOLOGIES PIT / CSE
</div>
</body>
</html>
OUTPUT:
Total in dollar: 25
AngularJS Strings
EXAMPLE
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"><
/script>
<body>
<div ng-app="" ng-init="firstName='Sonoo';lastName='Jaiswal'">
<p>My full name is: {{ firstName + " " + lastName }}</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="" ng-init="firstName='Sonoo';lastName='Jaiswal'">
<p>My full name is: <span ng-bind="firstName + ' ' + lastName"></span></p>
</div>
</body>
</html>
OUTPUT:
My full name is: Sonoo Jaiswal
AngularJS Objects
EXAMPLE
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"><
/script>
<body>
<div ng-app="" ng-init="person={firstName:'Sonoo',lastName:'Jaiswal'}">
<p>The name is {{ person.firstName }}</p>
CCS375 - WEB TECHNOLOGIES PIT / CSE
</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="" ng-init="person={firstName:'Sonoo',lastName:'Jaiswal'}">
<p>The name is <span ng-bind="person.firstName"></span></p>
</div>
</body>
</html>
OUTPUT:
The name is: Sonoo Jaiswal
AngularJS Arrays
"AngularJS Arrays" involve handling and manipulating collections of data
organized in an array format within AngularJS applications. This includes using
features like data binding, controllers, directives, and filters to manage array
elements efficiently. AngularJS facilitates displaying array elements in the
view, performing operations like iteration, filtering, sorting, adding, removing,
and updating array items, thereby enabling seamless interaction with array-
based data structures in web applications.
EXAMPLE
CCS375 - WEB TECHNOLOGIES PIT / CSE
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"><
/script>
<body>
<div ng-app="" ng-init="points=[1,15,19,2,40]">
<p>The first result is {{ points[0] }}</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="" ng-init="points=[1,15,19,2,40]">
<p>The first result is <span ng-bind="points[0]"></span></p>
</div>
</body>
</html>
OUTPUT:
The first result is 1
ANGULARJS DATA BINDING
CCS375 - WEB TECHNOLOGIES PIT / CSE
The one-way data binding is an approach where a value is taken from the data
model and inserted into an HTML element. There is no way to update model
from view. It is used in classical template systems. These systems bind data in
only one direction.
Data binding lets you treat the model as the single-source-of-truth in your
application. The view is a projection of the model at all times. If the model is
EXAMPLE PROGRAM:
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"><
/script>
<body>
<div ng-app="" ng-init="firstName='Ajeet'">
<p>Input something in the input box:</p>
<p>Name: <input type="text" ng-model="firstName"></p>
<p>You wrote: {{ firstName }}</p>
</div>
</body>
</html>
CCS375 - WEB TECHNOLOGIES PIT / CSE
OUTPUT:
In the above example, the {{ firstName }} expression is an AngularJS data binding
expression. Data binding in AngularJS binds AngularJS expressions with
AngularJS data.
Let's take another example where two text fields are bound together with two
ng-model directives:
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"><
/script>
<body>
<div data-ng-app="" data-ng-init="quantity=1;price=20">
<h2>Cost Calculator</h2>
Quantity: <input type="number" ng-model="quantity">
Price: <input type="number" ng-model="price">
<p><b>Total in rupees:</b> {{quantity * price}}</p>
</div>
</body>
</html>
OUTPUT:
CCS375 - WEB TECHNOLOGIES PIT / CSE
ng-if Directive:
SYNTAX:
Conditions like ng-if else and ng-if else then are sub parts of ng-if .
CCS375 - WEB TECHNOLOGIES PIT / CSE
EXAMPLE:
<h1>ngIf </h1>
<p *ngIf="showMe">
ShowMe is checked
</p>
<p *ngIf="!showMe">
ShowMe is unchecked
</p>
<h1>ngIf Else</h1>
<p *ngIf="showMe; else elseBlock1">
ShowMe is checked
</p>
OUTPUT:
ng-show:
ng-hide:
Used to hide an element based on a boolean expression.(or)
Conditionally hides an HTML element based on the truthiness of an
expression.
The ng-hide directive in AngularJS is a function using which an element
will be hidden if the expression is TRUE. If the Expression is FALSE, the
element will be shown. In the background, the element is shown or
hidden by removing or adding the .ng-hide CSS class onto the element
SYNTAX:
<div ng-show="condition">Content to show if condition is true</div>
<div ng-hide="condition">Content to hide if condition is true</div>
Example: ng-show
<h1> Guru99 Global Event</h1>
<div ng-app="DemoApp" ng-controller="DemoController">
<input type="button" value="Show Angular" ng-click="ShowHide()"/>
<br><br><div ng-show = "IsVisible">Angular</div>
</div>
<script type="text/javascript">
var app = angular.module('DemoApp',[]);
app.controller('DemoController',function($scope){
$scope.IsVisible = false;
CCS375 - WEB TECHNOLOGIES PIT / CSE
$scope.ShowHide = function(){
$scope.IsVisible = true;
}
});
OUTPUT:
Example: ng-hide
<h1> Guru99 Global Event</h1>
<div ng-app="DemoApp" ng-controller="DemoController">
<input type="button" value="Hide Angular" ng-click="ShowHide()"/>
<br><br><div ng-hide="IsVisible">Angular</div>
</div>
<script type="text/javascript">
var app = angular.module('DemoApp',[]);
app.controller('DemoController',function($scope){
$scope.IsVisible = false;
$scope.ShowHide = function(){
$scope.IsVisible = $scope.IsVisible = true;
} });
</script>
CCS375 - WEB TECHNOLOGIES PIT / CSE
OUTPUT:
ng-switch Directive:
Used to conditionally render content based on multiple conditions.
ng-switch, provide a way to dynamically control the visibility and rendering of
elements based on certain conditions. These directives enhance the flexibility
and responsiveness of AngularJS applications.
Angular evaluates the switch_expression at runtime and based on its
value displays or removes the elements from the DOM.
SYNTAX:
<div ng-switch="variable">
<div ng-switch-when="value1">Content for value1</div>
<div ng-switch-default>Default content</div>
</div>
EXAMPLE:
<div class='card'>
<div class='card-header'>
ngSwitch Example
</div>
<div class="card-body">
Input string : <input type='text' [(ngModel)]="num" />
CCS375 - WEB TECHNOLOGIES PIT / CSE
<div [ngSwitch]="num">
<div *ngSwitchCase="'1'">One</div>
<div *ngSwitchCase="'2'">Two</div>
<div *ngSwitchCase="'3'">Three</div>
<div *ngSwitchCase="'4'">Four</div>
<div *ngSwitchCase="'5'">Five</div>
<div *ngSwitchDefault>This is Default</div>
</div>
</div>
</div>
OUTPUT:
STYLE DIRECTIVES
Style directives in AngularJS are a way of applying CSS styles to
HTML elements dynamically, based on some conditions or expressions.
They can be useful for creating responsive and interactive web pages that
change their appearance according to the user‟s actions or data changes.
TYPES:
There are two main types of style directives in AngularJS:
ng-style and
ng-class.
Other types of Style directives in AngularJS includes:
CCS375 - WEB TECHNOLOGIES PIT / CSE
ng-blur
ng-click and
ng-disabled
PURPOSE:
The ng-style directive allows you to specify the style attribute for an HTML
element as an object or an expression returning an object. The object consists of
CSS properties and values, in key-value pairs.
ng-style directive:
The ng-style directive specifies the style attribute for the HTML element.
The value of the ng-style attribute must be an object, or an expression returning
an object.
The object consists of CSS properties and values, in key value pairs.
The ng-style Directive in AngularJS is used to apply custom CSS styles on an
HTML element. The expression inside the ng-style directive must be an
object. It is supported by all the HTML elements.
SYNTAX:
<element ng-style="expression"></element>
expression: It specifies the particular style to be implemented for the
respective element.
This is supported by all HTML elements.
Example program:
<!DOCTYPE html>
<html>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></sc
ript>
<body ng-app="myApp" ng-controller="myCtrl">
CCS375 - WEB TECHNOLOGIES PIT / CSE
<h1 ng-style="myObj">Welcome</h1>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.myObj = {
"color" : "white",
"background-color" : "coral",
"font-size" : "60px",
"padding" : "50px"
}
});
</script>
</body>
</html>
OUTPUT:
that is defined in the script (AngularJS) tag to apply background color to the h1
element i.e, WELCOME.
ng-class directive:
The ng-class directive dynamically binds one or more CSS classes to an
HTML element.
The value of the ng-class directive can be a string, an object, or an array.
If it is a string, it should contain one or more, space-separated class
names.
As an object, it should contain key-value pairs, where the key is the class
name of the class you want to add, and the value is a boolean value. The
class will only be added if the value is set to true.
As an array, it can be a combination of both. Each array element can be
either a string, or an object, described as above.
SYNTAX:
<element ng-class="expression"></element>
Example program:
<!DOCTYPE html>
<html>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></scr
ipt>
<style>
.sky {
color:white;
background-color:lightblue;
padding:20px;
font-family:"Courier New";
CCS375 - WEB TECHNOLOGIES PIT / CSE
}
.tomato {
background-color:coral;
padding:40px;
font-family:Verdana;
}
</style>
<body ng-app="">
<p>Choose a class:</p>
<select ng-model="home">
<option value="sky">Sky</option>
<option value="tomato">Tomato</option>
</select>
<div ng-class="home">
<h1>Welcome Home!</h1>
<p>I like it!</p>
</div>
</body>
</html>
OUTPUT:
CCS375 - WEB TECHNOLOGIES PIT / CSE
Here we use the ng-class directive to choose between two options i.e., Sky and
Tomato within the same class “Home”.
There are two types of ng-class directive. They are:
ng-class-even
ng-class-odd
ng-class-even:
The ng-class-even Directive in AngularJS is used to specify the CSS classes
on every even appearance of HTML elements. It is used to dynamically bind
classes on every even HTML element. If the expression inside the ng-class-
even directive returns true then only the class is added else it is not added.
The ng-repeat directive is required for the ng-class-even directive to work. It
is supported by all HTML elements.
SYNTAX:
<element ng-class-even="expression">Contents...</element>
expression: This parameter returns more than one class name or simply
specifies the CSS class for even appearance of HTML elements.
Example program:
<table>
<tr ng-repeat="item in items" ng-class-even="'even'">
<td>{{ item }}</td>
</tr>
</table>
</div>
OUTPUT:
Here the class “even” is used to highlight the even items everytime a new item
is added by clicking “Add item” button.
ng-class-odd:
The ng-class-odd Directive in AngularJS is used to specify the CSS classes
on every odd appearance of HTML elements. It is used to dynamically bind
classes on every odd HTML element. If the expression inside the ng-class-odd
directive returns true then only the class is added else it is not added. The ng-
repeat directive is required for the ng-class-odd directive to work. This
directive can be utilized for the styling of the items in a list or rows in a table,
although, can be used for remaining HTML elements, as well. It is supported
by all HTML elements.
SYNTAX:
<element ng-class-odd="expression">Contents... </element>
Example program:
CCS375 - WEB TECHNOLOGIES PIT / CSE
Here the class “odd” is used to highlight the odd items everytime a new item is
added by clicking “Add item” button.
ng-click directive:
The ng-click Directive in AngluarJS is used to apply custom behavior
when an element is clicked. It can be used to show/hide some element or
it can pop up an alert when the button is clicked.
In other words, The ng-click directive tells AngularJS what to do when an
HTML element is clicked.
SYNTAX:
<element ng-click="expression"></element>
Example program:
<!DOCTYPE html>
<html>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></scr
ipt>
<body ng-app="myApp">
<div ng-controller="myCtrl">
<p>Click the button to run a function:</p>
<button ng-click="myFunc()">OK</button>
<p>The button has been clicked {{count}} times.</p>
</div>
<script>
angular.module('myApp', [])
.controller('myCtrl', ['$scope', function($scope) {
$scope.count = 0;
$scope.myFunc = function() {
$scope.count++;
};
}]);
</script>
</body>
</html>
OUTPUT:
CCS375 - WEB TECHNOLOGIES PIT / CSE
ng-blur directive:
The ng-blur Directive in AngularJS is fired when an HTML element
loses their focus.
It doesn‟t override with element‟s original onblur event i.e. both the ng-
blur expression and original onblur event will execute.
SYNTAX:
<element ng-blur="expression">Contents... </element>
Example program:
<style>
.blurClass {background-color: lightgray;}
</style>
<script
src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>
<script>
var module = angular.module('myApp', []);
module.controller('MyCtrl', function($scope) {});
</script>
OUTPUT
ANGULARJS CONTROLLERS
AngularJS controllers control the data of AngularJS applications.
AngularJS controllers are regular JavaScript Objects.
AngularJS applications are controlled by controllers.
The ng-controller directive defines the application controller.
A controller is a JavaScript Object, created by a standard
JavaScript object constructor.
Controller Methods:
A controller can have methods (variables as functions)
The example demonstrated a controller object with two properties: lastName
and firstName.
EXAMPLE:
<!DOCTYPE html>
<html>
CCS375 - WEB TECHNOLOGIES PIT / CSE
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></scr
ipt>
<body>
<div ng-app="myApp" ng-controller="personCtrl">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{fullName()}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
$scope.fullName = function() {
return $scope.firstName + " " + $scope.lastName;
};
});
</script>
</body>
</html>
OUTPUT:
John
First Name:
Doe
Last Name:
personController.js
<script>
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
$scope.fullName = function() {
return $scope.firstName + " " + $scope.lastName;
CCS375 - WEB TECHNOLOGIES PIT / CSE
};
});
</script>
OUTPUT:
John
First Name:
Doe
Last Name:
AngularJS Scope:
The scope is the binding part between the HTML (view) and the
JavaScript (controller).
The scope is an object with the available properties and methods.
The scope is available for both the view and the controller.
When you make a controller in AngularJS, you pass the $scope object as
an argument
Root Scope:
All applications have a $rootScope which is the scope created on the
HTML element that contains the ng-app directive.
The rootScope is available in the entire application.
ANGULARJS FILTERS
Filters can be added in AngularJS to format data.
AngularJS provides filters to transform data:
currency Format a number to a currency format.
date Format a date to a specified format.
filter Select a subset of items from an array.
json Format an object to a JSON string.
CCS375 - WEB TECHNOLOGIES PIT / CSE
OUTPUT:
The name is DOE
LOWERCASE:
->The lowercase filter format strings to lower case:
-> From the above example, instead of uppercase, you put lowercase.(inside the
<div> tag)
EXAMPLE:
<p>The name is {{ lastName | lowercase }}</p>
ORDERBY:
The orderBy filter sorts an array:
EXAMPLE:
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></scr
ipt>
<body>
<div ng-app="myApp" ng-controller="namesCtrl">
<p>Looping with objects:</p>
<ul>
<li ng-repeat="x in names | orderBy:'country'">
{{ x.name + ', ' + x.country }}
</li>
CCS375 - WEB TECHNOLOGIES PIT / CSE
</ul>
</div>
<script>
angular.module('myApp', []).controller('namesCtrl', function($scope) {
$scope.names = [
{name:'Jani',country:'Norway'},
{name:'Carl',country:'Sweden'},
{name:'Margareth',country:'England'},
{name:'Hege',country:'Norway'},
{name:'Joe',country:'Denmark'},
{name:'Gustav',country:'Sweden'},
{name:'Birgit',country:'Denmark'},
{name:'Mary',country:'England'},
{name:'Kai',country:'Norway'}
];
});
</script>
</body>
OUTPUT:
Looping with objects:
Joe, Denmark
Birgit, Denmark
Margareth, England
Mary, England
Jani, Norway
Hege, Norway
Kai, Norway
Carl, Sweden
Gustav, Sweden
CCS375 - WEB TECHNOLOGIES PIT / CSE
CURRENCY:
The currency filter formats a number as currency:
EXAMPLE:
<div ng-app="myApp" ng-controller="costCtrl">
<h1>Price: {{ price | currency }}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('costCtrl', function($scope) {
$scope.price = 58;
});
</script>
<p>The currency filter formats a number to a currency format.</p>
OUTPUT:
Price: $58.00
The currency filter formats a number to a currency format.
FILTER:
The filter filter selects a subset of an array.
The filter filter can only be used on arrays, and it returns an array
containing only the matching items.
EXAMPLE
Return the names that contains the letter "i":
<div ng-app="myApp" ng-controller="namesCtrl">
<ul>
<li ng-repeat="x in names | filter : 'i'">
{{ x }}
</li>
CCS375 - WEB TECHNOLOGIES PIT / CSE
</ul>
</div>
{name:'Hege',country:'Norway'},
{name:'Joe',country:'Denmark'},
{name:'Gustav',country:'Sweden'},
{name:'Birgit',country:'Denmark'},
{name:'Mary',country:'England'},
{name:'Kai',country:'Norway'}
];
$scope.orderByMe = function(x) {
$scope.myOrderBy = x;
}
});
</script>
</body>
</html>
OUTPUT:
ANGULARJS ROUTING
The ng-Route module helps your application to become a Single Page
Application.
What is Routing in AngularJS?
If you want to navigate to different pages in your application, but you
also want the application to be a SPA (Single Page Application), with no
page reloading, you can use the ng-Route module.
The ng-Route module routes your application to different pages without
reloading the entire application.
EXAMPLE:
<!DOCTYPE html>
<html>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></scr
ipt>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-
route.js"></script>
<body ng-app="myApp">
<p><a href="#/!">Main</a></p>
CCS375 - WEB TECHNOLOGIES PIT / CSE
<a href="#!red">Red</a>
<a href="#!green">Green</a>
<a href="#!blue">Blue</a>
<div ng-view></div>
<script>
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl : "main.htm"
})
.when("/red", {
templateUrl : "red.htm"
})
.when("/green", {
templateUrl : "green.htm"
})
.when("/blue", {
templateUrl : "blue.htm"
});
});
</script>
<p>Click on the links to navigate to "red.htm", "green.htm", "blue.htm", or back
to "main.htm"</p>
</body>
</html>
OUTPUT:
Main
Red
CCS375 - WEB TECHNOLOGIES PIT / CSE
Green
Blue
Main
Click on the links to navigate to "red.htm", "green.htm", "blue.htm", or back to
"main.htm"
What does we Need?
To make the applications ready for routing, we must include the
AngularJS Route module:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-
route.js"></script>
Then we must add the ngRoute as a dependency in the application
module:
var app = angular.module("myApp", ["ngRoute"]);
Now the application has access to the route module, which provides
the $routeProvider. Use the $routeProvider to configure different routes
in the application:
app.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl : "main.htm"
})
.when("/red", {
templateUrl : "red.htm"
})
.when("/green", {
templateUrl : "green.htm"
})
.when("/blue", {
templateUrl : "blue.htm"
CCS375 - WEB TECHNOLOGIES PIT / CSE
});
});
$routeProvider
With the $routeProvider you can define what page to display when a user clicks
a link.
EXAMPLE:
Define a $routerProvider:
<!DOCTYPE html>
<html>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></scr
ipt>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-
route.js"></script>
<body ng-app="myApp">
CCS375 - WEB TECHNOLOGIES PIT / CSE
<p><a href="#/!">Main</a></p>
<a href="#!london">City 1</a>
<a href="#!paris">City 2</a>
<p>Click on the links to read about London and Paris.</p>
<div ng-view></div>
<script>
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl : "main.htm"
})
.when("/london", {
templateUrl : "london.htm"
})
.when("/paris", {
templateUrl : "paris.htm"
});
});
</script>
</body>
</html>
OUTPUT:
Main
City 1
City 2
Click on the links to read about London and Paris.
CCS375 - WEB TECHNOLOGIES PIT / CSE
Main
->Define the $routeProvider using the config method of your application. Work
registered in the config method will be performed when the application is
loading.
Controllers
With the $routeProvider you can also define a controller for each "view".
EXAMPLE:
<!DOCTYPE html>
<html>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></scr
ipt>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-
route.js"></script>
<body ng-app="myApp">
<p><a href="#/!">Main</a></p>
<a href="#!london">City 1</a>
<a href="#!paris">City 2</a>
<p>Click on the links.</p>
<p>Note that each "view" has its own controller which each gives the "msg"
variable a value.</p>
<div ng-view></div>
<script>
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/", {
templateUrl : "main.htm",
})
CCS375 - WEB TECHNOLOGIES PIT / CSE
.when("/london", {
templateUrl : "london.htm",
controller : "londonCtrl"
})
.when("/paris", {
templateUrl : "paris.htm",
controller : "parisCtrl"
});
});
app.controller("londonCtrl", function ($scope) {
$scope.msg = "I love London";
});
app.controller("parisCtrl", function ($scope) {
$scope.msg = "I love Paris";
});
</script>
</body>
</html>
OUTPUT:
Main
City 1
City 2
Click on the links.
Note that each "view" has its own controller which each gives the "msg"
variable a value.
Main
The otherwise method
CCS375 - WEB TECHNOLOGIES PIT / CSE
OUTPUT:
Main
Banana
Tomato
Click on the links to change the content.
Use the "otherwise" method to define what to display when none of the links are
clicked.
Nothing has been selected
MODULES
An AngularJS module defines an application.
The module is a container for the different parts of an application.
The module is a container for the application controllers.
Controllers always belong to a module.
Creating a Module:
A module is created by using the AngularJS function angular.module
The "myApp" parameter refers to an HTML element in which the
application will run.
CCS375 - WEB TECHNOLOGIES PIT / CSE
Now you can add controllers, directives, filters, and more, to your
AngularJS application.
EXAMPLE:
<html>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></scr
ipt>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
{{ firstName + " " + lastName }}
</div>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
</script>
</body>
</html>
OUTPUT:
John Doe
ANGULAR FORMS
Forms are collection of controls that is input field , buttons , checkbox and
these can be validated real time . Forms in AngularJS provides data-binding and
validation of input controls. As soon as a user of the form completes writing a
CCS375 - WEB TECHNOLOGIES PIT / CSE
field and moves to the next one it get validated and suggests the user where he
might have gone wrong .
Data-Binding
Input field :
SYNTAX :
<input type="text" ng-model="firstname">
<form>
<input id="myVar" type="checkbox" ngModel name="myVar"
#myVar="ngModel">
<p>The checkbox is selected: {{myVar.value}}</p>
<br />
<select ngModel name="mychoice" #myChoice="ngModel">
CCS375 - WEB TECHNOLOGIES PIT / CSE
<option>A</option>
<option>E</option>
<option>I</option>
<option>O</option>
<option>U</option>
</select>
<p>The selected option from Dropdown {{ myChoice.value }}</p>
</form>
OUTPUT :
Radio buttons used in the forms should allow only one field
to be selected at a time to make sure this is the case we should associate it with
only ngModel .
EXAMPLE :
<form>
<p>Select a radio button to know which Vowel it is associated to:</p>
<input value="A" type="radio" ngModel name="myVar"
#myVar="ngModel">
<input value="E" type="radio" ngModel name="myVar"
#myVar="ngModel">
<input value="I" type="radio" ngModel name="myVar"
#myVar="ngModel">
CCS375 - WEB TECHNOLOGIES PIT / CSE
OUTPUT :
<form>
<div class="form-group">
<label for="firstName">Name</label>
<input type="text"
id="firstName"
placeholder="Name">
</div>
<div class="form-group">
<label for="email">Email</label>
<input
type="text"
CCS375 - WEB TECHNOLOGIES PIT / CSE
id="email"
placeholder="Email">
</div>
<div class="form-group">
<label for="password">Password</label>
<input
type="password"
id="password"
placeholder="Password">
</div>
<div class="form-group">
<label for="phone">mobile</label>
<input
type="text"
id="phone"
ngModel name="phone"
#phone="ngModel"
placeholder="Mobile">
</div>
</form>
<p>{{ phone.value }}</p>
OUTPUT :
CCS375 - WEB TECHNOLOGIES PIT / CSE
FORM VALIDATION :
These all are the properties of the input field which can be either true or false.
Forms have the following states:
$pristine: It represents that the fields have not been modified yet.
$dirty: It illustrates that one or more fields have been modified.
$invalid: It specifies that the form content is not valid.
$valid: It specifies that the form content is valid.
$submitted: It specifies that the form is submitted.
These all are the properties of the form which can be either true or false. These
states can be used to show meaningful messages to the user.
EXAMPLE :
<!DOCTYPE html>
<html>
CCS375 - WEB TECHNOLOGIES PIT / CSE
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></scr
ipt>
<body ng-app="">
<p>Try writing in the input field:</p>
<form name="myForm">
<input name="myInput" ng-model="myInput" required>
</form>
<p>The input's valid state is:</p>
<h1>{{myForm.myInput.$valid}}</h1>
</body>
</html>
OUTPUT :
WEB SERVICES
DEFINITION:
Web services are XML-based information exchange systems that use the
Internet for direct application-to-application interaction. These systems can
include programs, objects, messages, or documents. A web service is a
CCS375 - WEB TECHNOLOGIES PIT / CSE
collection of open protocols and standards used for exchanging data between
applications or systems.
The Internet is the worldwide connectivity of hundreds of thousands of
computers of various types that belong to multiple networks. On the World
Wide Web, a web service is a standardized method for propagating messages
between client and server applications. A web service is a software module
that is intended to carry out a specific set of functions. Web services in cloud
computing can be found and invoked over the network.
The web service would be able to deliver functionality to the client that
invoked the web service.
A web service is a set of open protocols and standards that allow data to be
exchanged between different applications or systems. Web services can be
used by software programs written in a variety of programming languages and
running on a variety of platforms to exchange data via computer networks
such as the Internet in a similar way to inter-process communication on a
single computer.
Any software, application, or cloud technology that uses standardized web
protocols (HTTP or HTTPS) to connect, interoperate, and exchange data
messages – commonly XML (Extensible Markup Language) – across the
internet is considered a web service.
Web services have the advantage of allowing programs developed in different
languages to connect with one another by exchanging data over a web service
between clients and servers. A client invokes a web service by submitting an
XML request, which the service responds with an XML response.
just like a telephone directory has the name, address, and phone number of a
certain individual. So that a client application may figure out where it is.
The diagram depicts a very simplified version of how a web service would
function. The client would use requests to send a sequence of web service calls
to a server that would host the actual web service.
Remote procedure calls are what are used to make these requests. Calls to
methods hosted by the relevant web service are known as Remote Procedure
Calls (RPC). Example: Flipkart offers a web service that displays prices for
items offered on Flipkart.com. The front end or presentation layer can be
CCS375 - WEB TECHNOLOGIES PIT / CSE
written in .Net or Java, but the web service can be communicated using either
programming language. The data that is exchanged between the client and the
server, which is XML, is the most important part of a web service design.
XML (Extensible markup language) is a simple intermediate language that is
understood by various programming languages. It is a counterpart to HTML.
As a result, when programs communicate with one another, they do so using
XML. This creates a common platform for applications written in different
programming languages to communicate with one another.
For transmitting XML data between applications, web services employ SOAP
(Simple Object Access Protocol). The data is sent using standard HTTP. A
SOAP message is data that is sent from the web service to the application. An
XML document is all that is contained in a SOAP message. The client
application that calls the web service can be created in any programming
language because the content is written in XML.
(a) Business Functions can be exposed over the Internet: A web service is a
controlled code component that delivers functionality to client applications or
end-users. This capability can be accessed over the HTTP protocol, which
means it can be accessed from anywhere on the internet. Because all apps are
now accessible via the internet, Web services have become increasingly
valuable. Because all apps are now accessible via the internet, Web services
have become increasingly valuable. That is to say, the web service can be
located anywhere on the internet and provide the required functionality.
also make use of web services. A .NET application, for example, can
communicate with Java web administrations and vice versa. To make the
application stage and innovation self-contained, web administrations are used.
(c) Communication with Low Cost: Because web services employ the SOAP
over HTTP protocol, you can use your existing low-cost internet connection to
implement them. Web services can be developed using additional dependable
transport protocols, such as FTP, in addition to SOAP over HTTP.
WEB APPLICATION
DEFINITION:
A web-application is an application program that is usually stored on a remote
server, and users can access it through the use of Software known as web-
browser.
In general, a web application can contain online shops (or we can also say them
e-commerce shops), webmail's, calculators, social media platforms, etc. There is
also some kind of web application that usually requires a special kind of web
browser to access them. We cannot access those kinds of web applications by
using regular web- browsers. However, most of the web applications available
on the internet can be accessed using a standard web browser.
CCS375 - WEB TECHNOLOGIES PIT / CSE
If we talk about the web application in general, a web application usually uses a
combination of the server-side scripts such as PHP, ASP, for handling the
information/ data storage and retrieval of the data.
Some of them also use the client-side scripts such as JavaScript, HTML to
represent the data/information in front of the users, and some of the web
applications are also using both server-side and client-side at the same time.
Apart from that web applications also allow its users to create documents, share
them, or share the data/ information. By using the web application, users can
collaborate on same projects by event when they are not available on the same
geographical location.
After knowing that what a web application is, there may be a question hitting in
mind that how it will work.
A web application are generally coded using the languages supported by almost
every web-browsers such as HTML, JavaScript because these are the languages
that rely on the web browsers to render the program executable.
CCS375 - WEB TECHNOLOGIES PIT / CSE
Some of the web applications are entirely static due to which they not required
any processing on the server at all while, on the other hand, some web
applications are dynamic and require server-side processing.
To operate a web- application, we usually required a web server (or we can say
some space on the web-server for our programs/application's code) to manage
the clients' upcoming requests and required an application server.
The application server performs the task that requested by the clients, which
also may need a database to store the information sometimes. Application server
technologies range from ASP.NET, ASP, and ColdFusion to PHP and JSP.
A standard web application usually has short development cycles and can be
easily developed with a small team of developers. As we all know, most of the
currently available web applications on the internet are written using the
programming languages such as the HTML (or HyperText Markup
Language), CSS( or Cascading Style Sheets), and Javascript that are used in
creating front-end interface (Client-side programming).
1. In general, a user sends a request to the web-server using web browsers such
as Google Chrome, Microsoft Edge, Firefox, etc over the internet.
2. Then, the request is forwarded to the appropriate web application server by
the web-server.
3. Web application server performs the requested operations/ tasks
like processing the database, querying the databases; produces the result
of the requested data.
4. The obtained result is sent to the web-server by the web application server
along with the requested data/information or processed data.
5. The web server responds to the user with the requested or processed
data/information and provides the result to the user's screen .
o All the users are able to access the same version of the web application,
which eliminates all compatibility issues.
o It also reduces software piracy in subscription-based web applications, for
example, SAAS (or Software as a service).
o They also reduce the expense for end-users, business owners because the
maintenance needed by the business is significantly less.
o Web applications are flexible. A user can work from any geographical
location as long as he has a working internet connection.
o It just takes a moment to create a new user by providing a username,
password, and URL, and it's all.
o After the availability of the cloud, storage space is now virtually
unlimited as long as you can afford it.
o A web application can be programmed to run on a wide variety of
operating systems, unlike native applications that can run on a particular
platform.
o Any standard web application is developed with some basic programming
languages like HTML, CSS that are compatible and well known among
the IT professionals.
FRAMEFORKS
DEFINITION:
Web Application Framework or simply “web framework” is a software
framework that is designed to support the development of web applications
including web services, web resources, and web APIs. Frameworks are, in
short, libraries that help you develop your application faster and smarter!
Nowadays, the number of Web Frameworks has increased greatly. To help you
pick up the most suitable one for your Web Application, we have compiled a
list of 10 best frameworks available online, in your preferred language.
1. Ruby on Rails
Ruby on Rails is an extremely productive web application framework written
by David Heinemeier Hansson. One can develop an application at least ten
times faster with Rails than a typical Java framework. Moreover, Rails
includes everything needed to create a database-driven web application, using
the Model-View-Controller pattern.
Websites using Ruby on Rails are GroupOn, UrbanDictionary, AirBnb,
Shopify, Github
2. Django
Django is another framework that helps in building quality web applications. It
was invented to meet fast-moving newsroom deadlines while satisfying the
tough requirements of experienced Web developers. Django developers say the
applications are ridiculously fast, secure, scalable, and versatile.
Websites using Django are Disqus, Pinterest, Instagram, Quora, etc.
4. ASP.NET
ASP.NET is a framework developed by Microsoft, which helps us to build
robust web applications for PC, as well as mobile devices. It is a high
performance and lightweight framework for building Web Applications using
.NET. All in all, a framework with Power, Productivity, and Speed.
Websites using ASP.NET are GettyImages, TacoBell, StackOverflow, etc.
5. METEOR
Meteor or MeteorJS is another framework that gives one a radically simpler
way to build realtime mobile and web apps. It allows for rapid prototyping and
produces cross-platform (Web, Android, iOS) code. Its cloud platform,
Galaxy, greatly simplifies deployment, scaling, and monitoring.
Websites using Meteor are HaggleMate, WishPool, Telescope, etc.
6. Laravel
Laravel is a framework created by Taylor Otwell in 2011 and like all other
modern frameworks, it also follows the MVC architectural pattern. Laravel
values Elegance, Simplicity, and Readability. One can right away start
learning and developing Laravel with Laracasts which has hundreds of
tutorials in it.
Websites using Laravel are Deltanet Travel, Neighbourhood Lender, etc.
7. Express
CCS375 - WEB TECHNOLOGIES PIT / CSE
8. Spring
Spring, developed by Pivotal Software, is the most popular application
development framework for enterprise Java. Myriads of developers around the
globe use Spring to create high performance and robust Web apps. Spring
helps in creating simple, portable, fast, and flexible JVM-based systems and
applications.
Websites using spring are Mascus, Allocine, etc.
9. Play
Play is one of the modern web application framework written in Java and
Scala. It follows the MVC architecture and aims to optimize developer
productivity by using convention over configuration, hot code reloading, and
display of errors in the browser. Play quotes itself as “The High-Velocity Web
Framework”.
Websites using PLAY are LinkedIn, Coursera, LendUp, etc.
10. CodeIgniter
CodeIgniter, developed by EllisLab, is a famous web application framework
to build dynamic websites. It is loosely based on MVC architecture since
Controller classes are necessary but models and views are optional.
CodeIgnitor promises with exceptional performance, nearly zero-
configuration, and no large-scale monolithic libraries.
CCS375 - WEB TECHNOLOGIES PIT / CSE
WEB TOOLS
DEFINITION:
HTML.
CSS.
AngularJS.
Bootstrap.
PHP.
NextJS.
TypeScript.
ExpressJS.
HTML:
It can be a stand-alone software dedicated to code writing and editing or a
part of an IDE (Integrated Development Environment). An HTML editor
provides more advanced features and is specifically designed for developers to
create web pages more efficiently. It ensures every string of code is clean and
works properly.
CSS:
Cascading Style Sheets (CSS) is a stylesheet language used to describe the
presentation of a document written in HTML or XML (including XML dialects
such as SVG, MathML or XHTML). CSS describes how elements should be
rendered on screen, on paper, in speech, or on other media.
ANGULARJS:
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
CCS375 - WEB TECHNOLOGIES PIT / CSE
field to the application variable name.The ng-bind directive binds the content
of the <p> element to the application variable name
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/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>
BOOTSTRAP:
Bootstrap is a free, open source front-end development framework for the
creation of websites and web apps. Designed to enable responsive development
of mobile-first websites, Bootstrap provides a collection of syntax for template
designs.
PHP:
PHP is a server scripting language, and a powerful tool for making
dynamic and interactive Web pages. PHP is a widely-used, free, and efficient
alternative to competitors such as Microsoft's ASP.
<!DOCTYPE html>
<html>
<body>
<?php
echo "My first PHP script!";
CCS375 - WEB TECHNOLOGIES PIT / CSE
?>
</body>
</html>
NEXTJS:
Next.js enables you to create full-stack Web applications by extending the latest
React features, and integrating powerful Rust-based JavaScript tooling for the
fastest builds.
Next.js is an open-source web development React-based framework created
by Vercel, which is famous for its unique features such as Server-side
rendering and enhanced SEO. It has some additional features such as data
fetching utilities, dynamic API routes, optimized builds, etc. It is a framework
built upon React, Webpack, and Babel.
TYPESCRIPT:
TypeScript allows specifying the types of data being passed around within the
code, and has the ability to report errors when the types don't match. For
example, TypeScript will report an error when passing a string into a function
that expects a number. JavaScript will not.
EXPRESSJS:
Express. js is the most popular backend framework for Node. js, and it is an
extensive part of the JavaScript ecosystem. It is designed to build single-page,
multi-page, and hybrid web applications, it has also become the standard for
developing backend applications with Node.
CCS375 - WEB TECHNOLOGIES PIT / CSE
FIREBASE
Firebase is a product of Google which helps developers to build, manage, and
grow their apps easily. It helps developers to build their apps faster and in a
more secure way. No programming is required on the firebase side which makes
it easy to use its features more efficiently. It provides services to android, iOS,
web, and unity. It provides cloud storage. It uses NoSQL for the database for
the storage of data.
Firebase initially was an online chat service provider to various websites
through API and ran with the name Envolve. It got popular as developers used
it to exchange application data like a game state in real time across their users
more than the chats. This resulted in the separation of the Envolve architecture
and its chat system.
Features of Firebase:
This feature mainly includes backend services that help developers to build and
manage their applications in a better way. Services included under this feature
are:
scale. It stores data in the form of objects also known as Documents. It has a
key-value pair and can store all kinds of data like, strings, binary data, and even
JSON trees.
CCS375 - WEB TECHNOLOGIES PIT / CSE
Here majorly all the application performance and testing features are provided.
All the features required to check and manage before launching your application
officially are provided in this section. Services included are:
Crashlytics: It is used to get real-time crash reports. These reports can further
be used to improve the quality of the application. The most interesting part of
this service is that it gives a detailed description of the crash which is easier to
analyse for the developers.
Performance monitoring: This service gives an insight to the performance
characteristics of the applications. The performance monitoring SDK can be
used to receive performance data from the application, review them, and make
changes to the application accordingly through the Firebase console.
Test lab: This service helps to test your applications on real and virtual devices
provided by Google which are hosted on the Google Datacentres. It is a cloud-
based app-testing infrastructure which supports testing the application on a wide
variety of devices and device configurations
App Distribution: This service is used to pre-release applications that can be
tested by trusted testers. It comes in handy as decreases the time required to
receive feedback from the testers.
CCS375 - WEB TECHNOLOGIES PIT / CSE
Below listed are the advantages and disadvantages of using a Firebase backend:
Pros:
Free plans for beginners.
Real-time database is available.
Growing Community.
CCS375 - WEB TECHNOLOGIES PIT / CSE
Images from the Docker Hub anytime or anywhere via the internet. It provides
features such as you can push your images as private or public. Mainly
DevOps team uses the Docker Hub. It is an open-source tool and freely
available for all operating systems. It is like storage where we store the images
and pull the images when it is required. When a person wants to push/pull
images from the Docker Hub they must have a basic knowledge of Docker.
Let us discuss the requirements of the Docker tool.
Docker Commands
There is “n” no. of commands in docker following are some of the commands
mostly used.
1. Docker Run
2. Docker Pull
3. Docker PS
4. Docker Stop
5. Docker Start
6. Docker rm
7. Docker RMI
8. Docker Images
9. Docker exec
10.Docker Login
CCS375 - WEB TECHNOLOGIES PIT / CSE
Docker Engine
The software that hosts the containers is named Docker Engine. Docker
Engine is a client-server-based application. The docker engine has 3 main
components:
1. Server: It is responsible for creating and managing Docker images,
containers, networks, and volumes on the Docker. It is referred to as
a daemon process.
2. REST API: It specifies how the applications can interact with the
Server and instructs it what to do.
3. Client: The Client is a docker command-line interface (CLI), that
allows us to interact with Docker using the docker commands.
NODE JS
Node.js is an open-source server-side runtime environment built on
Chrome‟s V8 JavaScript engine.
It provides an event driven ,non-blocking (synchronous)I/O and cross-
platform run time environment for building highly scalable server-side
application using JavaScript.
CCS375 - WEB TECHNOLOGIES PIT / CSE
Node.js eliminates the waiting, and simply continues with the next request.
REACT
React is a free and open-source front-end JavaScript library for building
user interfaces based on components.
It is maintained by Meta and a community of individual developers and
companies.
React can be used to develop single-page, mobile, or server-rendered
applications with frameworks like Next.js.
React is a JavaScript-based UI development library.
Although React is a library rather than a language, it is widely used in
web development
Why React?
React‟s popularity today has eclipsed that of all other front-end development
frameworks. Here is why:
ReactJS Advantages
CCS375 - WEB TECHNOLOGIES PIT / CSE
Limitations
Features of React
Re-usability
Nested components
Render method
Passing properties
CCS375 - WEB TECHNOLOGIES PIT / CSE
React offers some outstanding features that make it the most widely
The above code shows how JSX is implemented in React. It is neither a string
nor HTML. Instead, it embeds HTML into JavaScript code.
Architecture
In a Model View Controller(MVC) architecture, React is the 'View'
responsible for how the app looks and feels.
React Native:
React Native is a framework that lets you build native mobile apps with
React.js. It is essentially a cross-platform framework that allows you to use
the same code to build apps for both iOS and Android.
DJANGO
Django is a free and open-source Python web framework that encourages rapid
development and clean, pragmatic design. It takes care of much of the hassle of
web development, so you can focus on writing your app without needing to
reinvent the wheel.
Django
AngularJS
Business websites
Educational websites
UI/UX DESIGN
UX stands for user experience. It refers to the overall experience that a user has
when using a website or application. This includes the UI, but it also includes
factors such as usability, performance, and customer support. A good UX makes
it easy for users to find what they are looking for and complete their tasks.
UI/UX and AngularJS are both important aspects of building web applications.
UI/UX is about making sure that the application is easy to use and understand,
CCS375 - WEB TECHNOLOGIES PIT / CSE
while AngularJS is a framework that can be used to build SPAs that provide a
fluid and responsive user experience.
Here are some of the ways that UI/UX and AngularJS can be used together
to build better web applications:
************