Beginning AngularJS

(WallPaper) #1

Chapter 2 ■ the BasiCs of angularJs


■ Note angularJs comes bundled with a trimmed-down version of jQuery called jqlite. generally speaking, however,


it is better to do things the “angular Way.” You will learn a lot more about what that means as the book progresses.


What Is a Framework?

Before exploring AngularJS in depth, let us consider exactly what AngularJS is. What do we mean by a “framework,”
and why would we want to use one? Might it be a good idea not to use one? Might it even be a good idea to develop
our own instead?
The dictionary definition tells us that a framework is “an essential supporting structure.” That sums up AngularJS
very nicely, although AngularJS is much more than that. AngularJS is a large and helpful community, an ecosystem in
which you can find new tools and utilities, an ingenious way of solving common problems, and, for many, a new and
refreshing way of thinking about application structure and design.
We could, if we wanted to make life harder for ourselves, write our own framework. Realistically, however, for
most of us, this just isn’t viable. It almost goes without saying that you need the support of some kind of framework,
and that this framework almost certainly should be something other than your own undocumented (or less than well
understood) ideas and thoughts on how things should be done. A good framework, such as AngularJS, is already well
tested and well understood by others. Keep in mind that one day others may inherit your code, be on your team,
or otherwise need to benefit from the structure and support a framework provides.
The use of frameworks isn’t uncommon; many programmers from all walks of life rely on them. Business
application developers use frameworks, such as the Microsoft Entity Framework, to ease their pain and speed
up development when building database-related applications. For example, Java programmers use the LibGDX
framework to help them create games. (We all need a little help.)
I hope I have sold you on the need for a framework and, more specifically, the fact that AngularJS is a great
choice. Now, I will spend the rest of this book getting you up to speed as quickly as possible, while putting you on a
solid footing to go further than I can take you within its pages. AngularJS is not difficult to learn, and, if you are like
me, you will enjoy its unique approach and its knack for making the complex seem considerably less so.


Downloading and Installing AngularJS


Downloading and installing AngularJS is easy, takes very little time, and doesn’t require your credit card. It is
completely free of charge (under the MIT license).
To download AngularJS, head on over to http://angularjs.org and follow these steps:



  1. Create a folder on your computer called BeginningAngularJS. Inside this folder, create a
    subfolder called js to contain your JavaScript files.

  2. On the AngularJS home page, click the Download button. You will see a dialog box like the
    one shown in Figure 2-1.

Free download pdf