Angularjs Design
Angularjs Design
2.4 Metadata
In angular, we can define metadata by using a
decorator. For example, if we make any component in
angular but how will angular identity it as a component? We
Figure 1. Angular architecture need to tell it by using the annotation @Component.
There are basically eight main things involved in angular
architecture: 2.5 Data Binding
Module Data binding is the main block of angular
Component architecture. It allows us to have communication between a
Template component and a template which is very much necessary to
Metadata render our business logic to the user in the form of data.
Service
There are four types of data binding provided by angular 2.
Data Binding
Interpolation: It is used to display a component property to a
Directive
Dependency Injection template or view. For this, we use double curly braces. We
can display anything using this i.e. str
2.1 Module Property Binding: Property binding allows us to directly
It is basically a block or piece of code that is access the element property of HTML. We can directly
responsible to perform a single task, it is an independent task. assign our variable to an HTML element. number, array, etc.
Angular applications can have any number of the module in Event Binding: This binding uses the event to bind value.
it. We can also export these modules in the form of a class. We have various events available for instance click.
The angular application should have at least one module. A Two-Way Binding: This is basically a combination of
module class must be decorated with the following property binding and event binding. In which we can
annotations i.e. @NgModule it takes a metadata object. simultaneously call our method and bind value to the element
property.
It has many properties which describe below.
Declarations: It is used to declare the view class 2.6 Service
that belongs to the current module. There are three It is an injectable class which is used to share data
types of classes provided by my angular i.e. among various class or application. It is also responsible to
component, pipes, and directive. In this, we define make the server call and get data to display. Any class
our custom component. annotated with @Injectable and making server calls can be
considered as service.
2.7 Directive things such as mobiles, books, apparel, jewelry, infant care,
They provide a special behavior to the DOM gifts, tools, etc. can be dispatched using online shopping
element. They are extended HTML attributes. system and of course you will get your requested ordered
Decorator Directive: There are many built-in directives like items at your doorstep.
ngModel, ngFor, ngIF, etc. many build-in directives provided
by angular. 3.4 Objectives
Component Directive: It is extended of @Directive decorates The objectives of the Project are
with template-oriented features. Promoting a service or product online
Template Directive: It is also known as Structural directive. Selling a service or product
It converts HTML into a reusable template Providing product support or customer service.
is to service HTTP requests from the browser. This is the Contain the logic for creating, managing, and
basis for round-trip web apps Of course, Angular exists in modifying the domain data (even if that means
the browser, which leads to a twist on the MVC theme, as executing remote logic via web services)
illustrated in the following figure 4.. Provide a clean API that exposes the model data and
operations on it.
Understanding Controllers/Components
Figure 4. HTTP requests from the browser Controllers, which are known as components in
Angular, are the connective tissue in an Angular web app,
The client-side implementation of the MVC pattern acting as conduits between the data model and views.
gets its data from server-side components, usually via a Components add business domain logic required to present
RESTful web service. The goal of the controller and the view some aspects of the model and perform operations on it. A
is to operate on the data in the model to perform DOM component that follows the MVC pattern should
manipulation so as to create and manage HTML elements Contain the logic required to set up the initial state
that the user can interact with. Those interactions are fed of the template
back to the controller, closing the loop to form an interactive Contain the logic/behaviors required by the template
application. to present data from the model
Angular uses slightly different terminology for its building Contain the logic/behaviors required to update the
blocks, which means that the MVC model implemented model based on user interaction
using Angular looks more like in the figure 5.
Understanding View Data
Understanding Views/Templates
Figure 5. Basic mapping of Angular building blocks to the Views, which are known as templates in Angular, are
MVC pattern defined using HTML elements that are enhanced by data
The figure 5. shows the basic mapping of Angular bindings. It is the data bindings that make Angular so
building blocks to the MVC pattern. To support the MVC flexible, and they transform HTML elements into the
pattern, Angular provides a broad set of additional features, foundation for dynamic web applications. I explain the
which I describe throughout the website. different types of data bindings that Angular provides in
detail in Part 2. Templates should
Understanding Models Contain the logic and markup required to present
Models the M in MVC contain the data that users work data to the user.
with. There are two broad types of model: view models,
which represent just data passed from the component to the
template, and domain models, which contain the data in a
business domain, along with the operations, transformations, The goal is to provide a user friendly platform
and rules for creating, storing, and manipulating that data, where the customers can easily shop their loved things from
collectively referred to as the model logic. our web-mart sites available on the web. With the help of this
Many Angular models will effectively push the logic to the they can carry out an online shopping from their home. Upon
server-side and invoke it via a RESTful web service because successful login the customers can purchase a wide range of
there is little support for data persistence within the browser, things such as mobiles, books, apparel, jewelry, infant care,
and it is simply easier to get the data you require over Ajax. gifts, tools, etc. can be dispatched using online shopping
system and of course you will get your requested ordered
Contain the domain data
items at your doorstep.
had to incur the high cost of owning a brick and mortar store.
At the end, it has been a win-win situation for both consumer
and sellers
Future Scope: Our designed online shopping system
provides a 24×7 service that is customers can surf the
website, place orders anytime they wish to. Also, the delivery
system works 24×7 hours a week. Some of the features that
can be modified and added to this system in the future
involve its implementation by local shopkeepers, where
shops will be providing an online interface to customers for
shopping and placing orders. Then some delivery persons
can perform their work. This will be adding on benefit for the
customers as it will save their time, plus it adds on for the
shopkeepers also, as people will continue to shop from local
shops rather than preferring to supermarkets every time.
Textbooks References: -
written by Krishna Rungta
Dayley