Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Architecture of a Web Application  Angular enables users to effortlessly move data

 The core of a Web application is its server-side from JavaScript code to the view, and react to
logic. The Web application layer itself can be user events without having to write any code
comprised of many distinct layers. The typical manually.
example is a three-layered architecture
Dependency Injection
comprised of presentation, business, and data
 Angular enables users to write modular services
layers.
and inject them wherever they are needed. This
Design Considerations improves the testability and reusability of the
When designing a Web application, the goals of a same services.
software architect are to minimize the complexity by
separating tasks into different areas of concern while Testing
 Tests are first-class tools, and Angular has been
designing a secure and high performance application.
built from the ground up with testability in
 Partition your application logically. mind. You will have the ability to test every part
 Use abstraction to implement loose coupling of your application—which is highly
between layers. recommended.
 Understand how components will communicate
with each other. Comprehensive
 Reduce round trips.  Angular is a full-fledged JavaScript framework
 Consider using caching. and provides out-of-the-box solutions for server
 Consider using logging and instrumentation. communication, routing within your application,
 Avoid blocking during long-running tasks. and more.
 Consider authenticating users across trust
Browser Compatibility
boundaries.
 Angular works cross-platform and compatible
 Do not pass sensitive data in plain text across
with multiple browsers. An Angular application
network.
 Design to run your Web application using a can typically run on all browsers (Eg: Chrome,
least-privilege account. Firefox) and operating systems, such as
Windows, macOS, and Linux.
Angular Architecture
 Angular is an open-source JavaScript MVC UNDERSTAND THE ARCHITECTURE
framework for the web applications. It extends Angular
 is a platform and framework for building single-
the HTML and makes it dynamic. Angular is
page client applications using HTML and
used to create Single Page Applications.
TypeScript. Angular is written in TypeScript. It
What is Angular? implements core and optional functionality as a
 Angular is a JavaScript framework that uses set of TypeScript libraries that you import into
HTML and TypeScript to create single-page your applications.
client apps. Its primary functionality is  The architecture of an Angular application relies
implemented as a series of TypeScript libraries on certain fundamental concepts. The basic
that you load into your projects. It is primarily building blocks of the Angular framework are
built in TypeScript. Angular components that are organized into
NgModules. NgModules collect related code
Few of Angular's most notable features:
into functional sets; an Angular application is
Custom Components defined by a set of NgModules. An application
 Angular enables users to build their always has at least a root module that enables
components that can pack functionality along bootstrapping, and typically has many more
with rendering logic into reusable pieces. feature modules.
 Components define views, which are
sets of screen elements that Angular
Data Binding can choose among and modify
according to your program logic and  Event binding lets your application
data. respond to user input in the target
 Components use services, which environment by updating your
provide specific functionality not application data.
directly related to views. Service  Property binding lets you interpolate
providers can be injected into values that are computed from your
components as dependencies, making application data into the HTML.
your code modular, reusable, and
This part of the lesson will demonstrate from creation
efficient.
to deployment of an Angular Web App.
MODULES
 Angular NgModules differ from and Step 1. Building the first application
complement JavaScript (ES2015) modules. An
NgModule declares a compilation context for a
set of components that is dedicated to an
application domain, a workflow, or a closely
related set of capabilities. An NgModule can
associate its components with related code,
such as services, to form functional units.
 Every Angular application has a root module,
conventionally named AppModule, which
provides the bootstrap mechanism that
launches the application. An application Step 2. Visual Studio Code Angular file structure.
typically contains many functional modules.
When the command above is executed, VSC will display
 Just like JavaScript modules, NgModules can
a welcome screen with the folder structure of budget-
import functionality from other NgModules,
app. The figure below presents the components and
and allow their own functionality to be
features of the Angular App recently created.
exported and used by other NgModules. We
will take this further on Routing.

COMPONENTS
 Every Angular application has at least one
component, the root component that connects
a component hierarchy with the page document
object model (DOM). Each component defines a
class that contains application data and logic,
and is associated with an HTML template that
defines a view to be displayed in a target
environment.
 The @Component decorator identifies the class
immediately below it as a component, and
provides the template and related component-
specific metadata.

Templates, directives, and data binding


 A template combines HTML with Angular
markup that can modify HTML elements before
they are displayed. Template directives provide Step 3. Deploying the localhost using ng serve
program logic, and binding markup connects command.
your application data and the DOM. There are
two types of data binding: Open a web browser and go to http://localhost:4200/
 is a way how a component is called in a
template. It is a unique identifier for a
component.

component
 is a directive with a template that allows
building blocks of a UI in an Angular application.
Components will always have a template, a
selector, and may or may not have a separate
style. Components are declared using
@Component.
 Generally speaking, each and every Angular
application has at least one component by
default—the root component. From there, it is
up to us, how to design our application. Usually,
you would create a component for separate
pages, and then each page would hold a list of
separate components. As a rule of thumb, a
component must fulfill the following criteria:
 Must have a class defined, which holds
data and logic; and
 Must be associated with an HTML
template that displays information for
the end user.

selector

You might also like