The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

maji1967 (2) [Avatar] Offline
#1
Note: I apologize for the code formatting. It was formatted correctly when I entered it, but the posted message did not preserve the code formatting

I have some comments on the the Hello Angular example in the first chapter. It is more complicated than it needs to be. I prefer the way AngularJS Succinctly gets started. It builds from a simpler example, one step at a time. It starts with a simple example:

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/ angularjs/1.0.4/angular.js"> </script>
</head>
<body ng-app>

This is your first angular expression: {{ 1 + 2 }}


</body>
</html>

There is less to explain here than in the Hello Angular example from the MEAP. This is all you need for a minimum angular application: include the angularjs script and use ng-app.

Then introduce controllers with a slightly larger example:

---- HTML file ----
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js"></script>
<script src="app.js"></script>
</head>
<body ng-app>
<div ng-controller="HelloCtrl">

{{greeting}} {{person}}


</div>
</body>

---- app.js file ----
// Defines hello world controller.
// $scope special argument to pass data to views.
function HelloCtrl($scope)
{
$scope.greeting = 'Hello';
$scope.person = 'World';
}

This kind of approach keeps things simple by introducing and explaining one concept at a time. The Hello Angular example in the MEAP introduced more concepts but did not clearly explain them, like ng-model and angular.model.
mmcconnell (8) [Avatar] Offline
#2
I agree. The hello world example in the first chapter is poorly put together. You should not show a "code snippet" for your first example. The body section in chapter 1. You should show the full html with the especially the script src for angular. Which I didn't know and had to google a example off the angular website.