16.07.2017 Views

AngularJS Essentials

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 8<br />

Installing packages<br />

After finding the desired package, you just need to execute the following command<br />

in order to download and install it:<br />

bower install <br />

To install the package, you just need to use this command with the package name<br />

as follows:<br />

bower install angular --save<br />

The angular package will be downloaded from its Git repository and placed inside<br />

the bower_components/ directory. With the --save option enabled, the bower.json<br />

file will be updated.<br />

We can check which packages are already installed in the application by means of<br />

the following command:<br />

bower list<br />

This command needs to be executed within the application directory, and the result<br />

will be shown in a list with the dependencies and versions of each package. This is<br />

an opportunity to evaluate whether it is possible to update a package.<br />

In order to update a package to its latest version, there is also an update command.<br />

This will try to update the outdated package. However, if there are dependencies to<br />

the outdated package, it will be kept:<br />

bower update<br />

To uninstall a package, we can follow the same installation procedure, just replacing<br />

the command, as follows:<br />

bower uninstall angularjs-file-upload --save<br />

The package will be removed from the application's bower components directory<br />

and also from the bower.json file.<br />

Using packages<br />

After we have installed a package, we need to update our index.html file in order<br />

to include it in our application. The following code is an example where we included<br />

the angular package in our project:<br />

<br />

[ 157 ]<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!