luchsamapparat (1) [Avatar] Offline
#1
Hi,

Right now I'm working through chapter 2. Here are some remarks, observations, suggestions smilie

- the current version of angular-cli (1.0.0-beta.32.3) prefixes all component selectors/elements with "app" by default: <app-summary>, <app-dashboard>, etc.
- also, angular-cli now automatically creates directory (e.g. when executing "ng generate component components/summary"), so you can drop the hint and "mkdir ..."
- when creating the summary component and the component dashboard component, the CLI calls provided by the text use different directories and in case of "summary" an invalid command ("create"):

ng create component components/summary

vs.
ng generate component component/dashboard


- in Listing 2.6, a <div> element within a <span> is invalid HTML; also I see no reason why the span is even there?
- also in Listing 2.6, the inline CSS styles of "h4" (color, margin) and "div.stock-card" (width) should be moved to the CSS file; it is bad practice and shouldn't be in a book that is supposed to teach newcomers how to code properly
- in Listing 2.7, why is the "stock" property typed as "any" instead of "StockInterface"?
- in Listing 2.8, the ":host" selector is not neccessary anymore as component styles are scoped automatically (see https://angular.io/docs/ts/latest/guide/component-styles.html#using-component-styles)

Also, I would suggest to improve variable naming in some places. Newcomers should learn early that precise naming is important and I often see that introductory resources often fail to convey this to their readers:

- in Listing 2.5, "serviceUrl" instead of "service", "stockSymbols" instead of "stocks"
- in Listing 2.9 and 2.10, "stocksService" instead of the too generic "service"


Thanks for the renewed effort to finish this book!
jeremy.wilken (206) [Avatar] Offline
#2
Thanks for the detailed feedback, and it should be noted that the original draft of this chapter and example was written long before the CLI even existed! You've pointed out a few things that I'll certainly address soon. I'll take it line by line when I'm ready to revisit chapter 2 soon.

I need to get all of the examples update to the latest CLI, but as you can imagine that takes time while I'm trying to write new content! I greatly appreciate these notes, and keep it coming!
thomasm (2) [Avatar] Offline
#3
Page 39 / Chapter 2.7

ng generate component component/dashboard is missing an s in the path
should be:
ng generate component components/dashboard



Listing 2.10

Variable subscription is missing:

subscription: any;
jeremy.wilken (206) [Avatar] Offline
#4
Thanks, will be updated!
476453 (4) [Avatar] Offline
#5
There is still no "subsriptions: any" in the 2.10 listing (6 month past). It fails to build without it. Also it is not very clear to me why should I use explicit any when I can just omit the property assignment, leaving the subscribe call only.
jeremy.wilken (206) [Avatar] Offline
#6
This might be due to some changes in the way the CLI has configured TypeScript to compile or TSLint to validate code. I had recently rebuilt all of the examples for Angular 5, so this should be better.