Getting Started With Angular 2nd Edition Stephen Adams pdf download
Getting Started With Angular 2nd Edition Stephen Adams pdf download
Adams download
https://ebookbell.com/product/getting-started-with-angular-2nd-
edition-stephen-adams-22526942
https://ebookbell.com/product/getting-started-with-angular-create-and-
deploy-angular-applications-1st-edition-victorhugogarcia-48081270
Getting Started With Angular Second Edition 2nd Edition Minko Gechev
https://ebookbell.com/product/getting-started-with-angular-second-
edition-2nd-edition-minko-gechev-11150184
https://ebookbell.com/product/getting-started-with-typescript-
includes-introduction-to-angular-thomas-claudius-huber-5726544
https://ebookbell.com/product/the-scalyr-guide-to-getting-started-
logging-as-quickly-as-possible-with-quickstart-guides-to-logging-in-
java-log4j2-php-ruby-rails-swift-scala-django-angular-meteor-
scalyr-50279264
Getting Started With Natural Language Processing Final Release 1st
Edition Ekaterina Kochmar
https://ebookbell.com/product/getting-started-with-natural-language-
processing-final-release-1st-edition-ekaterina-kochmar-46078164
https://ebookbell.com/product/getting-started-with-uno-platform-and-
winui-3-handson-building-of-crossplatform-desktop-mobile-and-web-
applications-that-can-run-anywhere-1st-edition-andrew-
hoefling-46364362
https://ebookbell.com/product/getting-started-with-secure-embedded-
systems-alexandru-radovici-47255148
Getting Started With Visual Studio 2022 Learning And Implementing New
Features 2nd Dirk Strauss
https://ebookbell.com/product/getting-started-with-visual-
studio-2022-learning-and-implementing-new-features-2nd-dirk-
strauss-47378260
https://ebookbell.com/product/getting-started-with-microsoft-viva-an-
end-user-guide-to-business-transformation-1st-edition-darce-
hess-47554262
Getting Started With Angular
Stephen Adams
This book is for sale at http://leanpub.com/getting-started-with-angular
This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing
process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and
many iterations to get reader feedback, pivot until you have the right book and build traction once
you do.
Component templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Categories of components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
An introduction to forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Creating a Reactive form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
When to use template forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
When to use Reactive forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Chapter 5: NgModules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
What are modules in Angular? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
The parts of the NgModule file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
How to create modules using the CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Creating modules for our Client Contact Manager application . . . . . . . . . . . . . . . . . 89
Adding our Client components to the ClientModule . . . . . . . . . . . . . . . . . . . . . . . 92
Adding Angular Material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
Chapter 1: What is Angular?
Welcome to this book on Getting Started with Angular. Throughout this book, we will be exploring
Angular and how to get started building applications with Angular. We will be looking at topics
such as how to set up an Angular application and how to use the tools the Angular team provide
to begin developing an Angular application. We will look at the architecture of a typical Angular
application and how components and modules are used to build sections of the app. We will explore
ways data is accessed and passed in an app and what mechanisms Angular provides for managing
data.
We will also look at more advanced topics, such as observables and RxJS, testing, and packaging an
application for production. We will even take a look at the NgRx, which is a library for managing
state.
In this chapter, we will introduce Angular, what it is, and the reasons it is an ideal choice for web
application development, as well as go through the features of Angular and what’s in the latest
release, version 8.
I will also introduce the demo application we are going to be building throughout the book. So, to
recap, in this chapter, we will cover the following topics: - Why are we looking at Angular? - What is
Angular? - Some examples of the types of applications that can be built with Angular - The history
of Angular, how it was started, and what problems it aimed to solve What are the new features of
Angular - What is the demo application we will be building throughout this book
What is Angular?
According to the official Angular docs, Angular is a platform that makes it easy to build applications
with the web. Awesome, but what does that actually mean? Well, Angular is a web application
framework that helps developers build web applications, web applications that can run on all
platforms, from desktop and mobile, which makes Angular an ideal choice for your next web
application.
The official documentation goes on to describe Angular as, [combining] declarative templates, de-
pendency injection, end-to-end tooling, and integrated best practices to solve development challenges.
Angular empowers developers to build applications that live on the web, mobile, or the desktop.
This perfectly describes what Angular is. Through templates, dependency injection, and end-to-end
tooling, Angular empowers developers to build web applications and applications that are built on
best practices.
Chapter 1: What is Angular? 2
Angular’s history
The history of Angular is an interesting one; first, there was AngularJS, and then came Angular.
AngularJS was created as part of an internal project within Google by Misko Hevery. He created
the first version of the project to make it easier for the designers within his team to build web
applications.
Misko wanted a way to extend the vocabulary of HTML in order for the designers to use HTML
tags that were more relevant to what they were designing. So, over a long weekend, yes, that’s a
weekend, Misko came up with the first version of AngularJS. The name Angular came from the
angled brackets that are at the beginning and the end of an HTML tag.
¹https:/ / blog. angular. io/ google-announces- grab- and- go- program- for- chromebooks- powered- by-angular- 7954c11900bd
Chapter 1: What is Angular? 3
Brad Green, Misko’s team leader at the time, asked Misko to work on a project called the Google
Feedback Tool, which was written in Google Web Kit (GWT), a Java-based framework. But, after
six months working on the project with GWT, the team found that it was extremely difficult to
work with. So, Misko said that he could rewrite the Feedback Tool project in two weeks using his
side project, AngularJS. Unfortunately, he took three weeks to complete the project, but he reduced
the number of lines of code down to 1,500 from the 17,000, which is the amount the old GWT version
had. And all this in three weeks as a solo developer!
Brad was obviously impressed, so he asked other developers to help Misko to work further on
Angular; Igor Minor (who still works on Angular along with Misko) and Shyam Seshadri both helped
Misko to complete the rewrite of the Google Feedback Tool and develop AngularJS further.
The next project the team worked on with AngularJS was the DoubleClick application that Google
had just purchased. The team was challenged to create a new landing page for DoubleClick; first,
they tried using GWT, but, after a two-week struggle, they turned to AngularJS, which Misko had
been promoting within Google. They were able to complete the landing page project within two
days using AngularJS. As a result of this success, the DoubleClick team decided to use AngularJS.
With this, the first version of AngularJS was released in May 2011.
But this is all about AngularJS; we’re not looking at the previous version. We’re interested in the
latest version of Angular, its second iteration. This new version of Angular came out in September
2016, after two and a half years of development, which shows how much thought has gone into the
new version.
Supported by Google
One of the main reasons to use Angular is because it is supported by Google. They don’t just sponsor
the development of Angular, they are the team behind the development of Angular; Unlike other
frameworks, which are supported by open source developers who work on fixing issues and creating
new features for a framework in their spare time, Angular has a full-time team constantly working
on supporting Angular.
Google has also provided a Long Term Support (LTS) plan for Angular, which shows that they plan
to support older versions of Angular for the next few years. In this LTS, we can see what versions of
Angular they provide support for and when older versions will no longer be supported. With Google
being so transparent in terms of their support of Angular, we can be sure that it has a long future.
This is extremely important for large businesses looking to select the framework they are going to
invest in for their next large-scale project. Being able to see that Angular has the support of a large
organisation like Google, and that there is an LTS plan, which shows that Angular will be supported
for the long term, makes the decision to pick Angular as their framework of choice a straightforward
one.
See the release dates from the official Angular website: https://angular.io/guide/releases.²
Built on TypeScript
Angular is built on TypeScript, a superset of JavaScript, from Microsoft. TypeScript brings so many
benefits, including Type interfaces and static typing. When we create objects and variables within
our code through static typing, the details of these types are known when we compile our code
and this helps to provide insight. So, bugs can be found at compile time instead of runtime. Not
only does TypeScript help us write better code, but it also allows tools such as VSCode to provide
IntelliSense of our code, which gives us better navigation, refactoring, and autocompletion, making
the experience of writing TypeScript far more enjoyable than JavaScript.
Along with providing a great development experience, as a result of using TypeScript, we have access
to all the ES2016/ES2017 features that aren’t yet available in JavaScript. TypeScript can provide
features that are still to be released in JavaScript. Being able to compile down to ES2015 (the version
of JavaScript that the browser understands), TypeScript can provide these latest features and still be
able to generate ES2015 code.
So, being built on TypeScript, Angular has access to all the latest features of the language and all
the fantastic tooling TypeScript provides.
range of features, including the following: - Creating the start of a project - Creates components,
services, directives, and other files using a simple command - Runs the application in the browser -
Reloads the application after each saved change so that the latest version is displayed in the browser
- It can update a project’s dependencies (other libraries used in a project) automatically - It can add
new libraries to the project - It can run all the unit tests in a project and the end-to-end tests
The Angular CLI is a great tool, and you’ll see as we proceed that learning Angular is an important
part of developing Angular applications. Many other frontend frameworks don’t have CLIs, and
those that do, they do not have the features of the Angular CLI.
There are also many conferences you can attend as an Angular developer to learn about the
new features of Angular and hear talks on different approaches to working with Angular. These
conferences are all over the world, and attended by the Angular team, so you can put your questions
to the team directly.
Not only are there conferences and meetups you can attend to learn about Angular, but there
are also so many online resources created by members of the Angular community that we
can access to learn about Angular. There are sites such as Ultimate Courses (https:// ultimate-
courses.com/courses/angular³) who provide courses on Angular and TypeScript.
There are also podcasts where you hear interviews with leaders of the Angular community, including
the Angular team. Podcasts such as Adventures in Angular and EggHead.io provide great interviews
with Angular developers.
To see the types of extra resources available for Angular, look at the Resources list on the
Angular website: https://angular.io/resources.⁵
As you can see, there are so many reasons to use Angular. We’re already on version 8, which shows
that the Angular team aren’t slowing down in terms of making Angular better and better. Let’s now
go through some of the recent features of Angular and see what’s new in Angular.
³https:/ /ultimatecourses. com/ courses/ angular
⁴https:/ / augury. rangle. io
⁵https:/ / angular. io/ resources.
Chapter 1: What is Angular? 7
Features of Angular
As we know, Angular provides a framework for developing web applications, but there is more
to Angular than just the building blocks of a web application (components, services, directives,
and so on). Angular has many features we can use as Angular developers to create fast, powerful
applications.
Schematics
The first feature we’re going to look at is schematics. This is a tool we can add to our workflow as
Angular developers, similar to how we use the Angular CLI. Schematics allow us to apply transforms
to our projects; we see an example of this when we ask the Angular CLI to create Components or
Services for our application.
When we call the CLI to create a Component file, it updates the filesystem where our project is kept.
So, the CLI is writing to the filesystem. You’ll see as we progress through this book that the Angular
CLI is really helpful at starting up and adding to a project.
While the CLI is a wonderful workflow tool, the role of schematics is to build upon this scaffolding
feature that the CLI supports. So, schematics allow us to add to the project in a way that we can
get the CLI to build new features as part of our project. For example, we could write a schematic
that will add a new library to a project. Or, we could have a schematic that adds a UI library, which
is standard across all projects within an organisation, to a new Angular project. If your company
has a set of UI components that need to be used in any project, we could write a schematic, which
is called through the CLI, that will add this UI library and create the new Angular project in one
process.
Schematics don’t write to our filesystem; they update a Tree object. This Tree object is a represen-
tation of our project’s filesystem, and when a schematic is run, this Tree object is updated with the
new updates, as set out in the schematic’s rules.
A schematic is a TypeScript file that has the rules for this new schematic set out within this file. In
the schematic file, the Tree data object can be updated and added to. So, we can update the Tree to
have new files, or add new libraries.
Tools such as Nrwl’s NX workspaces make use of schematics to add to the workflow of the Angular
CLI. So, if your project is using the NX workspaces, you can run commands that create libraries that
will be shared across teams.
To read more about NX and how it makes use of schematics, check out the NX workspaces
website: https://nx.dev/getting-started/nx-and-cli⁶.
⁶https:/ / nx. dev/ getting- started/ nx- and- cli
Chapter 1: What is Angular? 8
CLI prompts
Another feature is CLI prompts, where the Angular CLI will ask questions when we run a command
such as ng add or ng generate (both commands we will see in use throughout the book). The CLI
will prompt the user with questions such as Which stylesheet format would you like to use? or Would
you like to add Angular routing?.
We can also create these prompts for our own schematics, so when a team member is running one
of our schematics through the Angular CLI, they will be prompted with questions we want them
to be asked as the schematic is running in order for them to make different choices in terms of the
features our schematic may be adding to the project it is building.
The great benefit of having CLI prompts is that it helps developers discover new features of the CLI.
With each release of the CLI, the team can add new prompts, asking if we want to make use of any
new features that are part of a new Angular release.
Angular Elements
A really interesting new feature of Angular is Angular Elements. Angular Elements is the ability to
create custom web components that can be loaded into any modern browser.
Through these web components, we can create small Angular applications, which will run as part
of the web page. For example, if you have a web page built using ASP.Net, but a small section of the
page needs to use a piece of functionality that is already in an Angular application, with Angular
Elements, you can convert that Angular application to a web component that will run within the
ASP.Net page as a standalone piece of functionality.
Web components are a feature of the Web Platform (https://www.w3.org/Talks/2012/10- lea-
webplatform/wpd-talk/#intro⁷) and are supported by all modern web browsers. They allow us, as
web developers, to extend HTML by creating our own tags, which the browser will understand.
We can package up HTML, CSS, and JavaScript to create one of these Web Components, which the
browser can understand and run, just like it would a standard HTML tag.
With Angular Elements, a Web Component made with HTML, CSS, and JavaScript can also have the
Angular framework incorporated into the component, giving us access to all that Angular provides.
This means our component can, in essence, be a mini-Angular application, running within any
other type of web page. So, if we have a React page that needs to have a feature from an Angular
application, it can be loaded via Angular Elements.
One area where I’ve found Angular elements to be extremely useful is when there is an AngularJS
application that needs upgrading to Angular (AngularJS will no longer be supported after 2021).
With Angular Elements, we can create new features for an existing AngularJS site and then load
this new feature into the AngularJS site using Angular Elements. Then, as the AngularJS code is
rewritten in Angular, each new part can be loaded into the original application via an Angular
Element. Once everything has been written in Angular, the AngularJS code can be removed and we
⁷https:/ / www. w3. org/ Talks/ 2012/ 10-lea- webplatform/ wpd- talk/ #intro
Chapter 1: What is Angular? 9
now have everything written in Angular. The end user will not notice a difference. Well, perhaps
the application will load faster for them, but that’s not a problem!
CLI Builders
Another new feature in Angular is CLI Builders. This is a new API that allows us to add to, and
build upon, features with the Angular CLI.
We currently have schematics, which, as we know, allow us to write commands that the CLI can
use to generate new code for our applications. CLI Builders expands on this and provides an API we
can use to write commands to the CLI’s build system.
While schematics give us the ability to ask the CLI to generate new files or install new packages
for us, for example, adding Angular Material as part of a new application can be handled through
a schematic. With CLI Builders, the Angular team have expanded on this openness to the CLI and
have provided us with a way to write commands that can change the build system of Angular.
Through CLI Builders, we can run commands and tasks against the CLI to build our Angular
applications in any way we want. So, for example, as part of the build, we may need to have all
Angular Libraries built at the same time, or have all our tests run as part of the build; these tasks
can now be set up through the CLI Builder API.
Library updates
Along with all these new features in Angular, all the versions of RxJS, TypeScript, and Node have
been updated to their latest versions. So, we can start taking advantage of the new features from
these libraries as well.
Angular has some really nice new features; it is expanding in terms of opening up the Angular CLI
to us as developers so that we can tailor the CLI to our needs; it’s also adding features to help with
the upgrade from AngularJS to Angular.
The way we write Angular applications, which we will learn in this book, still applies to Angular 8,
so once you know how to create applications with Angular, you can then explore further these new
features in Angular.
As part of this application, we are going to use a fantastic third-party library called the In- Memory
Web API (https://github.com/angular/in-memory-web-api⁹). This library allows us to create local,
in-memory storage similar to a database that we can save data to, access data from, and remove data
from, all via API calls.
Using this library means we have a source of storage for our Client Contacts Manager Application
and we can make API calls to this storage system without having to set up a local database of external
API. We can just focus on learning how to write Angular.
Once you’ve finished reading this book, and you’ll want to create your own application to practice
what you’ve learned, I highly recommend looking at the In Memory Web API as a temporary data
source for your practice applications; it’s not a replacement for a real database, but is really easy to
use for small demo applications.
Summary
So, we have looked at what Angular is, what problems it aims to solve, and a bit about the history
of Angular. We have looked at some examples of the types of projects we can build using Angular
and have gone through the new features of Angular.
Finally, we’ve looked at what we will be building throughout this book, how we will be creating
a mini-CRM, which gives us the ability to really explore the features of Angular. So by the end of
this book, you should not only have an understanding of both frameworks, but you’ll also be able
to create apps in Angular.
Next, we are going to start working the Angular version of the application. We’re going to start
building the app using the Angular CLI, and we will look at the architecture of an Angular
application.
⁹https:/ / github. com/ angular/ in- memory- web- api
Chapter 2: Angular Architecture
Now that you know what Angular and Ionic are, it’s time to start looking into things more deeply.
In the first part of this book, we’re going to be concentrating on Angular, and in this chapter, we’re
going to be looking at the architecture of an Angular application.
How are we going to do that? Well, we need an application to look at, in order to see the various
parts of the application: what they are, what they do, and how they are built. In order to do this, we
need to create an Angular application, and in order to do that, we need to install the Angular CLI.
So, let’s do that.
In this chapter, we’ll be looking at the architecture of an Angular application to see how the Angular
framework structures a typical application. You’ll also learn how the various parts of an Angular
application are pieced together. Here’s what you’ll be learning in this chapter:
Overview of Angular
Angular is more than just a framework; it’s now both a framework and a platform. In the previous
version, AngularJS was just a frontend framework, but now, with more advanced frontend tools,
Angular has grown from a frontend framework into a complete platform.
Being a complete platform, Angular can now be used to create a wider variety of applications;
before, AngularJS was used for creating Single-Page Applications (SPAs). As more and more teams
used AngularJS as the basis for their tools, AngularJS could be used to develop different types of
applications.
With Angular (the second version of AngularJS), as there are more mature tools for frontend
development, the Angular team has been able to expand Angular from a frontend framework into
this complete platform. It’s a platform that allows developers to create web apps, mobile apps,
desktop apps, and even server-side applications.
Chapter 2: Angular Architecture 13
Why do I need to install the CLI when I’ve just installed Node? The answer is, we need
Node Package Manager (NPM), to install the Angular CLI for us.
This command is telling npm to go and install the Angular CLI package globally (so that it’s available
from anywhere, within any folder). Then, npm goes off and downloads the latest version of the
Angular CLI and installs it for you. The days of CDs or floppy disks are long gone; it’s all command-
line magic now.
Now, we should have the Angular CLI installed, and it’s time to create our first Angular app. This
isn’t going to be the Client Contact demo app that I mentioned earlier; this is just going to be a small
app with which we can look through the code and see how an Angular app is made and what the
structure of the app is.
To create an Angular application, we need to go back into our Terminal or Command Prompt and
navigate to a folder in which we can work. Once we have navigated to our development folder, we
simply run the command ng new, along with the name of the Angular app we’re building. So, for
this, type in the following:
ng new angular-architecture
¹⁰https:/ /nodejs.org/en/
Chapter 2: Angular Architecture 15
This will create a new folder within the development folder, called angular-architecture. The CLI
uses the name you provide to create a new folder in which to create the application. Once that has
run, you should see the following message:
Project 'angular-architecture' successfully created
There are other great editors available for writing Angular applications, like Webstorm, Atom, and
even Visual Studio itself. All of these are good editors for Angular, but we are using Visual Studio
Code because it’s free and good with Angular. With the power of the Angular CLI, you could (in
theory) use Notepad with the Terminal to create an Angular application, but why would you do that
to yourself?
If you don’t already have Visual Studio Code (more commonly called VSCode), go to https://code.visualstudio.com/¹¹
and download the latest version. Once that’s installed, let’s open up VSCode and navigate to our
newly created Angular app.
You should see the following screenshot:
¹¹https:/ / code. visualstudio. com/
Chapter 2: Angular Architecture 16
This is VSCode with our new app loaded. We can now use the features of VSCode to go through the
app and see how it’s structured.
First, let’s expand the source tree folder; you should see the full src folder, as follows:
Chapter 2: Angular Architecture 17
There are a few main parts to the app; the first thing you’ll notice is that there are two main folders,
the src folder and the e2e folder. The src folder contains all the source code for your app. It will
contain all the HTML, CSS, and TypeScript code of your app. The e2e folder contains all your end-
to-end tests, and these tests can be run to test how your app runs in the browser. However, we are
looking at the architecture of an Angular app, so let’s carry on with that.
Within the src folder, you’ll see the app folder, and inside of that you’ll see the following files:
• app.component.css
• app.component.html
• app.component.spec.ts
• app.component.ts
• app.module.ts
We now have a small Angular app, which we can take a look at while we go through the architecture
of an Angular application.
Chapter 2: Angular Architecture 18
• Modules: Modules are the glue that holds an application together. They are single TypeScript
files that reference all the other files used within the application. They allow us as Angular
developers to group the functionality of our application together.
• Components: Components are the building blocks of the application. They are single pieces of
functionality in our application, which are linked together under a module. Components can
have visual elements to them, which allow the user to interact with the application.
• Services: Services are single TypeScript classes used to access information and share it between
components.
When you think of an Angular application, you can think of it as a tree; the module is the trunk
of the tree, and the components are the branches of the tree, branching out of the module, with
services being passed into components to share data throughout the application. Everything is tied
together through the module, and as the complexity of your Angular application grows, the number
of modules you’ll have in your application will grow.
Now let’s take a more in-depth look at each of these three parts, starting with modules.
This is the main App module; as you can see, it’s made up of four main parts: the declarations array,
the imports array, the providers array, and the bootstrap array. There is another part to a module
that is not shown in this example: the Exports array.
So, what do all these different arrays do? Well, let’s look at each one, as follows:
• declarations: This contains the components, directives, and pipes that are part of this module.
• imports: This contains other modules, whose classes are needed by components of the module
they are being imported into.
• providers: This contains any services that are required by components. If a service is added to
the module level, it is available to all components that are part of the module, but services can
also be imported at just the component level.
• bootstrap: This contains the main component, or the root component, which starts the whole
application. Only the root module (in our architecture application it’s the app.module.ts file)
that we have opened can have a Bootstrap array.
• export: This contains a list of declarations that are available by components in other modules.
One of the first things to point out is the use of a decorator to tell Angular about the details of
this module. As you can see, the @NgModule is a decorator. Angular sees this and knows that this
TypeScript class is a module, and, that the details within the @NgModule decorator are all parts of
this module. So, through this decorator, Angular knows that this module has its own version of
AppComponent that belongs to this module. It then imports another module called BrowserModule,
and when Angular boots up, it should use the AppComponent as part of this Bootstrap process.
NgModule’s main role is to tell the framework what components belong where when the application
is being compiled. For example, suppose that I have a component called ComponentOne.ts, and in
the same application, another developer working on the project also creates a new component and
decides to call it ComponentOne.ts, adding it to the same project. The compiler wouldn’t know which
ComponentOne to use when the application was running. By using a module, we can say that one
Chapter 2: Angular Architecture 20
ComponentOne belongs to this module, and the other one belongs to another module. Then, when
the compiler is running the application and it is running the code that belongs to a module, the
compiler knows which ComponentOne file to use. This helps to group functionality together and
allows a different developer to work on separate parts of an application without affecting the part
of the application that another developer is working on.
With NgModule, we can say that one ComponentOne.ts belongs to the admin modules, admin.module.ts,
and the other ComponentOne.ts belongs to the ordering module, ordering.module.ts; so now, each
component has a context of where it belongs. So, Angular knows where each ComponentOne belongs
and that they are separate components. Although naming components the same name is never a
good idea, it’s sometimes unavoidable, especially when incorporating a third-party library into your
project.
We will be going further into NgModule in Chapter 5, NgModules, where we will not only look into
a more complex module file, but will also start to create modules for our demo app.
1 @Component({
2 selector: 'app-root',
3 templateUrl: './app.component.html',
4 styleUrls: ['./app.component.css'
5 })
6 export class AppComponent {
7 title = 'app'
8 }
This is the entry component of our application. If you look at the app.module.ts file, you’ll see
that AppComponent is set to be the Bootstrap component for the application. That means that this
component will be the start of the application, and the template for this component will be the first
thing a user will see when the app has loaded in the browser.
Again, the component is a TypeScript class that is using the @Component decorator to tell Angular
about the details of the component. In this @Component decorator, we can see that the component
has an HTML template called app.component.html and a CSS file called app.component.css.
The @Component decorator also tells Angular that the selector, or HTML tag, for this component is
app-root; this is the HTML that the selector generates:
<app-root></app-root>
Chapter 2: Angular Architecture 21
The selector name is used to create the HTML tag that Angular knows about, so when that HTML tag
is seen in other component templates, Angular knows what component to use and what component’s
template to display.
In our example component within the class, we can see a property of the component class called
title. This property is available in the associated template of the component, which you can see in
the following section of app.component.html:
1 <div style="text-align:center">
2 <h1>Welcome to {{ title }}!</h1>
3 </div>
There’s more that can be added to the component class besides properties that are available to the
associated template/view. The functionality of the template is defined in the component class, as
well as data and common functionality provided by Services is loaded into the component class,
making it available to the component template.
We’ll be looking at components more closely in a later chapter. We’ll be creating new components for
our demo application and looking more closely at the relationship between the component class and
the component template. But for now, this should give you an understanding of the basic structure
of an Angular component.
Now, we are going to look at Services: how they are structured, and how Decorators are used to
define what a Service is in Angular.
Dependency Injection (DI) is the method that Angular uses to tell components what services the
component can consume. DI is not just an Angular-specific concept; there are many frameworks
that use Dependency Injection, and not just frontend frameworks.
Angular has always used DI. Even from the early versions of AngularJS, DI has been the method
that Angular has used to inject Services into components.
In our angular-architecture project, we don’t have a service automatically generated for us by the
Angular CLI. This is because (as we know), services are used to manage data and logic within our
application. This changes from application to application. The Angular CLI team couldn’t get the
CLI to generate a service for us that fits the needs of our application, it’s impossible. So, they don’t
provide a service for a very basic Angular application (although, as we will see in Chapter 3, Getting
Started with the Angular CLI, the CLI can generate Services); we have to create one ourselves.
While the angular-architecture application doesn’t have a service, we can still take a look at an
example to see the structure of a Service.
In the Angular official documentation, there is an example application called Tour of Heroes, and
it is possible to download and view the source code of this example application. (It’s well worth
doing this, as the Tour of Heroes application has great examples of the various parts of an Angular
application. It was written by some of the leading experts within the Angular community, so it’s a
great example of some best practices for building Angular apps.)
In this Tour of Heroes application, there are many Services that we can take a look at to see how a
Service is structured. This is one of the main services, which loads a list of Heros from an external
API:
As you can see, it is a simple TypeScript class with a Constructor and a single method called
getHeros(). It also calls another service, called BackendService (showing an example of this
modularity that services provide, where one service does one single task and uses another to perform
another task, in this case providing data).
Chapter 2: Angular Architecture 23
What’s missing from this Service is the Decorator that tells Angular that this class can be
consumed/injected into Components. The Decorator that provides Angular with this information is
called the Injectable decorator, and it looks like this:
1 @Injectable({
2 providedIn: 'root',
3 })
4 export class HeroService {}
When the @Injectable decorator is added to a class, this tells Angular that this class and its
functionality can be passed into components and other services, using Dependency Injection.
To get a better understanding of how a service is linked to a module, let’s create a simple Service for
our angular-architecture app. Within VSCode, we need to open the Terminal panel (if you open
the Terminal drop-down menu in the main navigation, you should see the New Terminal link).
This is shown in the following screenshot:
This will open a new Terminal window at the bottom of VSCode, with the folder of our project
already loaded. In this new window, type the following:
ng generate service demo
Chapter 2: Angular Architecture 24
This will tell the Angular CLI to create a new service called demo within our source code. We will
be looking at the commands of the CLI in more detail later on, in Chapter 3, Getting Started with
the Angular CLI.
So, you should have a nice new service called demo.service.ts, which looks like the following:
Pretty impressive? Well, not really, because it doesn’t actually do anything yet, but it does
demonstrate how the TypeScript class is using the @Injectable decorator so that Angular knows
that this class can be injected into components and other services via DI.
Now that we have this service, let’s add it to our app.module.ts file so that Angular knows what
context this service belongs under.
Open the app.module.ts file, which should look like this:
To add the service, we type the name of the service to the providers array, like this:
Chapter 2: Angular Architecture 25
1 providers: [
2 DemoService
3 ],
VSCode should automatically set the import statement at the top to where the service TypeScript
class is stored, as shown here:
The final stage is to have the app.component.ts consume the new DemoService. To do that, we add
the service to the constructor of the component class, as follows:
Here, we have given the DemoService a local name of demoService, so if we want to access any of
the functions of the service within our component class, we simply use the following local reference:
this.demoService.methodCall();
So, we’ve now created a service using the CLI, added it to our module so Angular knows about it,
and added it to our main component class; that’s quite a lot. Now, we are going to take a look at
why Angular is built with TypeScript and what benefits this brings to us as Angular developers.
that TypeScript has a larger set of features that JavaScript doesn’t have, but when you save your
TypeScript file, the TypeScript compiler transforms the TypeScript code you have written to just
plain JavaScript. But why do we need TypeScript?
Well, the simple reason is that JavaScript, while a fantastic language, moves slowly when adding
new features. For a new feature to be added to the language, it has to be discussed by all the
relevant committees (JavaScript, while not being owned by anyone, is governed by a committee of
community leaders and representatives for the various web browser developers). These committees
need to discuss a new feature: how it’ll be implemented, how it’ll be used by developers, and the
benefits it brings. Then, they make it part of the ECMAScript standard, which is a document that
sets out what languages based on ECMAScript should be able to do.
Then, all the various browsers need to start adding support for these new features of JavaScript into
their browser, and the JavaScript engine, which is part of the browser. Therefore, when one browser
supports a new feature, this allows a developer to use that feature and for it to work in the browser.
Another browser company may not have implemented it, so when a user views a website or web
application using this new feature, it won’t work for them.
The introduction of new features is a slow process in JavaScript. It has become faster over the last
few years as the popularity of JavaScript has grown, but there are still a lot of hurdles for a new
language feature to be added to plain JavaScript.
Microsoft decided that they would create a new language—not to replace JavaScript (like they tried
with JScript a few years ago), but so that this new language would have the features that they
believed a modern web language should have. With their knowledge and experience in developing
tools, they would create a compiler for this new language that would generate JavaScript that used
its set of features to replicate the new features of this new language. This would allow the developer
to use the latest features of a modern web language and leave the compiler to work out how to
mimic these features in JavaScript.
This is what TypeScript aims to do; Microsoft can add all the new features they want to TypeScript—
features they believe a language should have (based on their experience with other languages, such
as C#). These features include types, interfaces, and modules (although these are now available in
JavaScript), and there is no wait for these features to be available to developers. Developers know
that support for these new language features is made by the TypeScript compiler.
Not only does TypeScript provide great features that aren’t available in JavaScript, it also provides
great tooling for developers to use in order to find issues and bugs within their code before it’s even
run in the browser.
For example, we are using VSCode throughout this book to build both our Angular and Ionic
applications, and both applications use TypeScript. As we go through building out these applications,
TypeScript, and more specifically the TypeScript compiler, is inspecting our code and is aware of all
the different parts of our code. If we add a property to a class then use that class in another class
(as we did when we added our demo service to our main component class), the TypeScript compiler
knows what functions are available from this demo service. Therefore, when we go to use the service
in the component class, VSCode knows what is available and gives us developer insight into what
functions are available as we type.
For me, the main benefit that TypeScript provides is this insight into our code as we write. An
application can become more and more complex, and trying to remember all the moving parts
is extremely hard, but with TypeScript and the great tooling it gives us, there is less we need to
remember and a lower chance of bugs appearing in the code.
As well as great tooling, TypeScript allows us to make abstractions when we are defining the model
of our application. Using interfaces, which TypeScript provides us, allows us to define how our
application will be structured and the relationships between the parts of the data model that our
application uses. This is something we will be looking at in the next section, where we’ll go over the
architecture of our Client Contacts application.
Moving from JavaScript to TypeScript can be difficult, to start with. When you start writing
TypeScript, the compiler keeps telling you the mistakes and problems with your code as you type,
while JavaScript would just let you get away with these simple mistakes. Therefore, you would think
that JavaScript is quicker to develop with, but the more and more you work with TypeScript, the
better your code becomes and the better you become. Soon, you’ll be writing code that is easier to
read and understand.
There’s also going to be a Company section, because each contact must belong to a company, as our
fictional salesperson needs to be able to find the contacts for a particular company.
So, in the Company section, the salesperson will be able to do the following:
If we think about the model behind this application, there are three main data models: the contact,
the company, and the salesperson who uses the application. Each of them can have an Interface that
defines the details of the model and what each model representation can do.
So, the interface for the salesperson could be as follows:
1 interface SalesPerson {
2 firstname: string;
3 lastname: string;
4 email: string;
5 password: string;
6 jobtitle: string;
7 startDate: Date;
8 active: boolean;
9 accessLevel: number;
10 relatedCompanies: Companies[];
11 relatedContacts: Contacts[];
12 }
Here, we have set some properties that a salesperson will have: firstname, email, startDate, and so
on. We’ve also created properties that they may have for relatedCompanies and relatedContacts.
Both of these are defined as arrays with a type of Companies and Contacts, which are Types we
define for the data model of the other sections of the application.
The Contact interface looks as follows:
Chapter 2: Angular Architecture 29
1 interface Contact {
2 id: number;
3 firstname: string;
4 lastname: string;
5 email: string;
6 jobtitle: string;
7 status: string;
8 isActive: boolean;
9 relatedCompany: Company;
10 notes: string;
11 }
Here, we are defining the model of a contact to have an ID; a first name and last name; some
details about their job, such as the status; and the Company they belong to, which is set as the
relatedCompany property that is a type of Company.
Finally, our Company Interface will look as follows:
1 interface Company {
2 id: number;
3 name: string;
4 address1: string;
5 address2: string;
6 town: string;
7 city: string;
8 postCode: string;
9 country: string;
10 contactEmail: string;
11 numberOfStaff: string;
12 industry: string;
13 isActive: boolean;
14 }
As you can see, we’ve created a Company type that has a name, address details, some information
about the number of staff, and the industry the company works in. This Company type is the type
that is used for the relatedCompany property of the Contact type. Now that we have a few interfaces
mapped out, it shows how the features of TypeScript allow us to abstract the model of the application
into types that our application will use.
What else do we need for our application? Well, here’s an initial list of the components and services
we need for this application:
That’s a lot of components and services, and there may be more! We won’t create these now; instead,
we’ll start to create these components and services using the Angular CLI, which is what we will be
looking at in Chapter 3, Getting Started with the Angular CLI.
Summary
In this chapter, we set up a new Angular application using the CLI, and we reviewed the main parts of
the application. We discussed how modules, components, and services are the building blocks of an
Angular application. Then, we looked at why the Angular team made the decision to use TypeScript
as their language of choice for Angular. We took a look at the architecture for the demo Angular
application that we are going to start building in Chapter 3, Getting Started with the Angular CLI,
when we will be taking a more detailed look at the Angular CLI.
Chapter 3: Getting Started with the
Angular CLI
In the previous chapter, we took a quick look at the Angular CLI; we used it to create our
architecture-application project. Now, we’re going to be taking a closer look at the CLI.
We’ll be using the CLI to create our demo project and to run the application in the browser. Then,
we will see how to use the CLI to create new components and templates. We’ll also look at other
commands you can pass to the CLI, and see what other tasks it can perform. Once we’ve gone
through all this, we’ll take a look at schematics, the latest feature of the CLI. We’ll cover what
schematics are, and how they are being used.
In this chapter, we will cover the following:
These are just a few of the features of the Angular CLI. As you can see from this list, having a tool
that you can use to run these tasks as you are developing is beneficial.
Now that you can build an Angular application without a CLI, you can create all the files yourself,
set up a build tool that’ll minimise all your files, and run the application in the browser. You can set
up Karma to run all your unit tests. But all these tasks would take a lot of time within a project to
set up and manage.
Chapter 3: Getting Started with the Angular CLI 32
You should see the version number appear in Terminal/Command Prompt, which should be the
same as the version you have just downloaded.
OK; now that Node is installed, it’s time to get the Angular CLI. To do this, in the Terminal/Command
Prompt window, type the following:
npm install -g @angular/cli
In this command, we are telling Node to use the Node Package Manager (NPM) to install globally,
so that it is available in any folder you choose.
Once this has run, we can check that the Angular CLI has been installed by typing this command:
ng -v
This will tell us what version of the Angular CLI we have installed, which, at the time of writing, is
version 8.0.2.
That’s it; the Angular CLI has been installed. Now, we’re going to look at how we can use it, and
we’ll start to create our Client Contacts Angular app.
cd Dev
That has taken us to our Dev folder; what we should do next is create a folder for our Angular apps.
So, in Terminal, type the following:
mkdir Getting-Started-With-Angular-8
This will create a new folder called Getting-Started-Angular-8. This is where we will build both of
our Angular applications. Now, you need to cd into this new directory using the following command:
cd Getting-Started-With-Angular-8
Once we’re there, we need to tell the Angular CLI to create a new Angular application. To tell the
Angular CLI to create an application, we simply use the following command:
ng new Client-Contacts-Manager
This will create a new folder within the Getting-Started-Angular-8 folder called Client-Contacts-Manager,
where the CLI will create all the shell code of the application. As the CLI runs, it will ask you the
following two questions:
Basically, the CLI is asking: Do we want to add routing to the application? Routing is how you set up
navigation throughout an application, and by saying yes, we are asking the CLI to create a Routing
module, where all our links can be added to a separate module. We will be going over Routing in
Chapter 6, Routing and Navigation; but for now, say Yes.
The second question is asking: What CSS format do we want to use in this application? We can use
just plain CSS for the application, but we are going to choose SASS.
Chapter 3: Getting Started with the Angular CLI 34
After agreeing to these two questions, the CLI will create a folder called Client-Contacts-Manager
and add all the scaffolding code for the application. Once the CLI has finished, cd into the folder
that has just been created:
cd Client-Contacts-Manager
This will open Visual Studio Code, with our newly created Angular application loaded. You should
see the following screenshot:
This screenshot shows Visual Studio Code with the Client-Contacts-Manager folder loaded in the
left-hand side project view.
Exploring VSCode
Let’s take a minute here to explore VSCode. From the preceding screenshot, we can see that there
are two main panels in the VSCode editor. On the left side, we have the Project Explorer, which
shows us all the files of our project, or the project opened in VSCode. On the right-hand side is the
editor, where we can see any files that have been opened.
Chapter 3: Getting Started with the Angular CLI 35
If we double-click on a file listed in the left-hand side Project Explorer, the selected file opens in the
right-hand Editor view. We can also use the shortcut command of Ctrl/Cmd + P to open the quick
access tool, which allows us to start typing in the name of a file we want to open. Once we’ve found
the file we want to access, all we do is press Enter, and that file will open in the Editor view. This is
another way to open files, and it’s a lot faster than searching through the Project View panel.
The panel below the Editor view shows the built-in Terminal, which is an application that all
computers have, whether it’s macOS or PC, which allows us as developers to type commands to tell
the computer to do something. We’ve used Terminal a few times now when installing the Angular
CLI and creating our development folder, but now we can see we have access to this Terminal tool
within VSCode, which makes it easy to access while we are building our application.
Now we’ve had a brief overview of VSCode, we can carry on building our Angular application.
Awesome, we are on our way to Angular mastery!
The Angular CLI has compiled all the source code of the application and started running a new
Node server making the application accessible at this web address: http://localhost:4200.
If you open this URL in your favourite browser, you should see the newly generated Angular app as
follows:
What we have here is our application running in the browser. As part of building a new application,
the CLI generates an initial page with some helpful links. These links are as follows:
• Tour of Heroes: A demo application created by the Angular team, which you can read about
in the Angular documentation and see a live demo
• CLI Documentation: A link to the wiki page of the Angular CLI team with details on how to
use the CLI and a list of other commands
• Angular blog: The Medium blog of the Angular team, well worth reading and checking
regularly to see what the team are up to
Chapter 3: Getting Started with the Angular CLI 37
Now as we’ve seen, running the app and then opening the browser is easy, but there is an even
easier way to get the application running in the browser. We can tell the CLI to not only start the
application but open the browser and load the application for us.
So now, close the browser and in VSCode terminal use CMD/CTRL + C to stop the Node service
running. Then, within the same Terminal window, type the following command:
ng serve -o
This tells the CLI to compile the application, start the Node service running again, and even open
the browser loading the application again at http://localhost:4200.
You should now see the same web application running in your browser as we did before, but this
time, there was no need to go and open the browser and enter the URL of the site, the Angular CLI
has done all this for you.
This is a small example of how the Angular can help improve the development processes. There are
many commands that the CLI provides, which you can use to tell the CLI to help you as you build
out your Angular application. Let’s pause for a minute to look at some of these commands and how
they can help.
A command is a term for instructions we type into the Command Line Interface (CLI).
Let’s now go to the official Angular website to find the official documentation for the CLI as shown
in the following screenshot:
Chapter 3: Getting Started with the Angular CLI 38
Once the site has loaded, we will see a list on the left-hand side of all the available commands. There
are the following:
• ng add: Used to add third-party libraries to an existing application, we will be using this soon
to add Angular Material.
• ng build: Used to compile the complete application into a /dist folder or a folder provided by
an argument.
• ng config: Allows you to either view or set configuration settings for your app, these
configuration settings can be passed as JSON.
• ng doc: Opens the official Angular docs website, if you want to find a specific topic, add the
keyword as an argument
• ng e2e: This will run the end-to-end tests of the application.
• ng generate: Command to create/generate new components, services, and other parts of your
Angular application. This command we will be using a lot over the next few chapters.
Chapter 3: Getting Started with the Angular CLI 39
• ng help: This provides you with a help menu for the Angular CLI.
• ng lint: Runs linting over your application’s codebase.
• ng new: This starts the process to create a new Angular application, we’ve already used this
command.
• ng run: This starts running a custom target for your application. In your package.json file, you
can add custom commands that ng run will start for you.
• ng serve: Starts the local Node server so you can access the site in the browser. ng test: Starts
the running of all the Unit Tests you create for your application.
• ng update: This will update the application and any dependencies in the application, very
useful when a new version of Angular is released.
• ng version: Tells you the version number of the Angular CLI currently being used.
• ng xi18n: Extracts any xi18n messages within your application, used as part of adding multi-
language support to your application.
Wow, that is a lot of commands, 15 in total, and there may be more coming in future releases of the
Angular CLI. This shows how much you can do with the CLI and how you will rely on it as part of
your day-to-day Angular development. We are now going to take two of these commands and use
them with our newly created Client Contacts Manager application.
This will start a process where the CLI will install all the dependencies and libraries needed for
Angular Material, it will also install the main CSS file into our main index.html file.
After running this command, the CLI will be asking you a series of questions as follows:
• Do you want to use HammerJS for handling gestures? This gives you support for gestures on
mobile.
• Do you want to use animations? This will give your app the smooth effects that you’d expect
with that Material design style
This shows the Angular CLI after it has asked its setup questions and updated the modules
automatically. As you can see, main.ts has been updated, so has app.modules.ts. This is where
the CLI has added the links and modules of Angular Material to our project automatically.
So now that this is complete, let us run our application to see how it looks in the browser. Again we
can use the CLI to run the app, using the following command:
ng serve -o
This will open the browser with the updated application, looking like the following screenshot:
Chapter 3: Getting Started with the Angular CLI 41
Now, the site doesn’t look completely different, but that’s because we haven’t started adding Material
specific components, but you can see that the fonts are different and the padding around the side of
the application has been reduced. This is all because of the newly installed CSS file of the Angular
Material library the CLI has installed.
We will be going further into Unit Testing in a later chapter, but what we really want to look at is
how we can use the CLI to run these (and our future tests for us).
Again, open Terminal and navigate to our Client-Contacts-Manager folder, once there, enter the
following command:
ng test
Two things should happen; first, the Terminal window should show that it is compiling the
application, the same way the CLI compiles the application when running it in the browser.
In here you’ll see that it says TOTAL: 3 SUCCESS in green and Executed 3 of 3 SUCCESS, this
three of three is in reference to the three unit tests that have been created by the Angular CLI and
that these three tests have passed.
Unit tests can pass or fail, a test that is passing means the code that the test checks does
Chapter 3: Getting Started with the Angular CLI 43
what the test expects it to do. The code passes the tests checks. A failed test means the
code doesn’t pass the tests checks. We will go into this further in Chapter 10, Testing later.
The second thing you should see is the browser opens; this is caused by the Angular CLI opening the
browser to show the output of the Karma test runner the library Angular uses to run the tests. The
Angular CLI uses Karma, a popular testing framework, to go through and perform all the available
tests on the main code base. You should see the browser looking like this screenshot:
This is the browser window that the Angular CLI has opened for us, showing the report Karma
generates; as you can see at the top, we have a nice green bar and this shows all our tests have
passed; if they hadn’t, it would be red. In the world of Unit tests, green is good, red is bad.
One of the things you can do is have two Terminal windows open or one window divided into two
sections if your Terminal of choice does that; in one window have the Angular CLI running the app
and in the other have the Angular CLI running the ng test command. This will lead to your tests
Exploring the Variety of Random
Documents with Different Content
Palæstra, 69 sq., 78 sq.
Pantheism, 136.
Parmenides, 24.
Parthenon, 24, 106.
Pedagogical State, 172 sqq.
Pedagogue, 68.
Peleus, 7.
Pentathlon, 88.
Pericles, 105 sqq.
Perioikoi, 44.
Periods of Greek Education, 26 sqq.
Persian Education, 115 sqq.
Personality, 202.
Pherecydes, 53.
Phiditia, 44.
Philolaus, 39.
Philosophy, Rise of, 22.
Philosophy and Individualism, 93 sqq.
Physical Culture, 189.
Physicians in Homer, 17.
Pindar, 39.
Pisistratus, 35, 98, 178.
Plato, 29, 112, 133 sqq., 134, 136, 137, 142.
Play, 66, 181 sqq.
Plotinus, 29, 225 sqq., 228 sqq.
Poetesses, 21.
Poetry, Value of, for Education, 73 sqq.
"Professional," Meaning of, 195.
Prometheia, 24.
Proxenus of Atarneus, 155.
Purgation, 7, 76.
Pythagoras, 29, 52 sqq., 149.
Pythias, 156.
Q
Quadrivium, 144, 198.
Quintilian, 29, 214 sqq.
R
Reading, 75.
Rhapsodes, 23.
Rhetorical Schools, 209, 217.
Roman Education, 216 sqq.
Roman Period, 27.
Ruling and Ruled, 176.
Running, 79.
S
School Education in Athens, 67.
" Buildings " " 69.
" Rooms " " 77.
Scipio Africanus, 216.
Singing, 75.
Slaves, 12.
Social Life in Greece, 18.
Socrates, 24, 107 sqq.
Socratic Method, 109.
Solon, and his Laws, 68, 98.
Soothsayers in Homer, 17.
Sophists, 23, 100 sq.
Spartan Education, 41, 43 sqq.
Spartan Girls, 49.
" Government, 44.
" Ideal, 42.
" Mercilessness, 45, 50.
" Women, 44.
Stagira, 155 sq.
State, Meaning of Term, 174.
State as a School, 91.
Stilo, Lucius Ælius Præconinus, 217.
Stoics, 210.
Supercivic Man, 136, 234.
T
Theban Education, 28.
Themistes, 17.
Theories of Education, 28.
Therapeuts, 212.
Thomas Aquinas, 165.
Thucydides' Daughter, 37.
Tragedy, 84.
Trivium, 144, 198.
U
University Education, 90.
" of Alexandria, 212.
" of Athens, 211.
W
Wilhelm Meister, 173.
Wingless Victory, 63.
Wisdom, the Ideal of Athens, 63.
Women, Education of, 49, 124.
Worth, 16, 48.
Worth, Aristotle's Pæan to, 4.
Wrestling, 81 sqq.
Writing, 75.
X
Xenophon, 29, 113, 114 sqq.
" Memoirs of Socrates, 123.
" Œconomics, 124.
" on Female Education, 124 sqq.
Greek:
On p. 22 αἴτια has not been changed to αἰτία (as in LSJ) as it may be an acceptable
alternative form.
Similarly on p. 223 παιδοτρίβεια has not been changed to παιδοτριβία (as in LSJ).
*** END OF THE PROJECT GUTENBERG EBOOK ARISTOTLE AND
ANCIENT EDUCATIONAL IDEALS ***
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
ebookbell.com