JavaScript Primer: Preparing the Example Project

For this chapter, I will be demonstrating some basic JavaScript techniques and some helpful general-purpose utility methods that AngularJS provides to supplement the JavaScript language.

Ensure that the angular.js, bootstrap.css, and bootstrap-theme.css files are in the web server angularjs folder, and create a new HTML file called jsdemo.html. Set the contents of the HTML file to match those in Listing 5-1.

Listing 5-1. The Initial Contents of the jsdemo.html File

<!DOCTYPE html>

<html>

<head>

<title>Example</title>

<script src=”angular.js”></script>

<script type=”text/javascript”>

console.log(“Hello”);

</script>

</head>

<body>

This is a simple example

</body>

</html>

If you use the browser to navigate to the jsdemo.html file, you will see the result shown in Figure 5-1. In this chapter, my emphasis is on the JavaScript language, and the content displayed by the browser isn’t important.

I’ll also be using the todo.json file that I created in Chapter 2. You can copy this file from your previous example or re-create it so that it contains the content shown in Listing 5-2.

Listing 5-2. The Contents of the todo.json File

[{ “action”: “Buy Flowers”, “done”: false },

{ “action”: “Get Shoes”, “done”: false },

{ “action”: “Collect Tickets”, “done”: true },

{ “action”: “Call Joe”, “done”: false }]

Source: Freeman Adam (2014), Pro AngularJS (Expert’s Voice in Web Development), Apress; 1st ed. edition.

Leave a Reply

Your email address will not be published. Required fields are marked *