farata / angular2typescript Goto Github PK
View Code? Open in Web Editor NEWCode samples from the book Angular 2 Development with TypeScript
License: MIT License
Code samples from the book Angular 2 Development with TypeScript
License: MIT License
The first sample project: hello-world-ts
When putting the projet to run on http-server and hitting the URL . The page doesn't load and looking to the CONSOLE of the browser, i get the error
GET https://unpkg.com/[email protected]/client/shim.min.js net::ERR_ABORTED 404
In Charter 5 list 5.4,The second bold notes says :
This <input> element is represented by the ngFormControl named **search**.
Should says "This element is represented by the ngFormControl named searchInput."
Server side IntelliJ IDEA 2016.2 node plugin > 'dev' task on chapter 8 http_websockets_sample:
/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run-script dev
> @ dev /Users/pb/work/angular2typescript/chapter8/http_websocket_samples
> nodemon build/auction-rest-server-angular.js
[nodemon] 1.10.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node build/auction-rest-server-angular.js`
Listening on 127.0.0.1 8000
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] starting `node build/auction-rest-server-angular.js`
Listening on 127.0.0.1 8000
MacOS Chrome Version 51.0.2704.106 (64-bit) - http://localhost:8000/ console:
browser_adapter.ts:82EXCEPTION: Error in ./BidComponent class BidComponent_Host - inline template:0:0BrowserDomAdapter.logError @ browser_adapter.ts:82BrowserDomAdapter.logGroup @ browser_adapter.ts:93ExceptionHandler.call @ exception_handler.ts:58(anonymous function) @ application_ref.ts:417ZoneDelegate.invoke @ zone.js:323onInvoke @ ng_zone_impl.ts:72ZoneDelegate.invoke @ zone.js:322Zone.run @ zone.js:216NgZoneImpl.runInner @ ng_zone_impl.ts:104NgZone.run @ ng_zone.ts:219ApplicationRef_.run @ application_ref.ts:405ApplicationRef_.bootstrap @ application_ref.ts:429(anonymous function) @ application_ref.ts:169ZoneDelegate.invoke @ zone.js:323onInvoke @ ng_zone_impl.ts:72ZoneDelegate.invoke @ zone.js:322Zone.run @ zone.js:216(anonymous function) @ zone.js:571ZoneDelegate.invokeTask @ zone.js:356onInvokeTask @ ng_zone_impl.ts:61ZoneDelegate.invokeTask @ zone.js:355Zone.runTask @ zone.js:256drainMicroTaskQueue @ zone.js:474ZoneTask.invoke @ zone.js:426
the validation seems to be working, the form and fields get the ng-valid and ng-invalid class applied. However the has-error never gets applied and [class.hidden]="!formModel.hasError(...)" is not working either
> 192-168-1-146:angular2typescript pb$ cd chapter8/http_websocket_samples/
192-168-1-146:http_websocket_samples pb$ npm install
192-168-1-146:http_websocket_samples pb$ tsc -w
server/auction-rest-server-angular.ts(1,26): error TS2307: Cannot find module 'express'.
server/auction-rest-server-angular.ts(2,23): error TS2307: Cannot find module 'path'.
server/auction-rest-server-angular.ts(6,51): error TS2304: Cannot find name '__dirname'.
server/auction-rest-server-angular.ts(7,51): error TS2304: Cannot find name '__dirname'.
server/auction-rest-server-angular.ts(27,28): error TS2304: Cannot find name '__dirname'.
server/auction-rest-server-angular.ts(35,21): error TS2339: Property 'find' does not exist on type 'Product[]'.
server/auction-rest-server.ts(1,26): error TS2307: Cannot find module 'express'.
server/auction-rest-server.ts(31,21): error TS2339: Property 'find' does not exist on type 'Product[]'.
server/bids/bid_server.ts(1,26): error TS2307: Cannot find module 'express'.
server/bids/bid_server.ts(2,23): error TS2307: Cannot find module 'path'.
server/bids/bid_server.ts(4,22): error TS2307: Cannot find module 'ws'.
server/bids/bid_server.ts(9,39): error TS2304: Cannot find name '__dirname'.
server/bids/bid_server.ts(10,51): error TS2304: Cannot find name '__dirname'.
server/bids/bid_server.ts(14,28): error TS2304: Cannot find name '__dirname'.
server/bids/bid_server_send.ts(1,26): error TS2307: Cannot find module 'express'.
server/bids/bid_server_send.ts(2,23): error TS2307: Cannot find module 'path'.
server/bids/bid_server_send.ts(4,22): error TS2307: Cannot find module 'ws'.
server/bids/bid_server_send.ts(9,39): error TS2304: Cannot find name '__dirname'.
server/bids/bid_server_send.ts(10,51): error TS2304: Cannot find name '__dirname'.
server/bids/bid_server_send.ts(16,28): error TS2304: Cannot find name '__dirname'.
server/hello_server.ts(1,23): error TS2307: Cannot find module 'http'.
server/hello_server_json.ts(1,23): error TS2307: Cannot find module 'http'.
server/my-express-server.ts(1,26): error TS2307: Cannot find module 'express'.
server/simple_websocket_server.ts(1,26): error TS2307: Cannot find module 'express'.
server/simple_websocket_server.ts(2,23): error TS2307: Cannot find module 'path'.
server/simple_websocket_server.ts(4,22): error TS2307: Cannot find module 'ws'.
server/simple_websocket_server.ts(8,39): error TS2304: Cannot find name '__dirname'.
server/simple_websocket_server.ts(9,51): error TS2304: Cannot find name '__dirname'.
server/simple_websocket_server.ts(15,28): error TS2304: Cannot find name '__dirname'.
10:52:02 AM - Compilation complete. Watching for file changes.
In PDF version, page 436, says:
If you remove
implements Payable
Should be If you remove implements IPayable
In PDF version, page 56, says:
To load and compile a module on application startup, you need to invoke the bootstrapModule module
Should say "To load and compile a module on application startup, you need to invoke the bootstrapModule method"
I read an article about "multi-root" (https://yakovfain.com/2017/04/06/angular-cli-multiple-apps-in-the-same-project/) and there I found a link to this repo, like an example of such a solution. Unfortunately, however, during the compilation or launch, a bug a lot of pops up.
C:\2018\66\TUTORIALE\angular2typescript\Angular4\router-samples [master ≡ +4 ~1 -0 !]
λ npm run-script buildAll
> hello-ng4@0.0.0 buildAll C:\2018\66\TUTORIALE\angular2typescript\Angular4\router-samples
> ng build --app main && ng build --app queryparams && ng build --app child && ng build --app guards && ng build --app outlets && ng build --app lazy && ng build --app resolver
Date: 2018-02-02T09:46:16.244Z
Hash: c6843fa7a8b41c8c1b66
Time: 19107ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 14.3 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 218 kB [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.4 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.33 MB [initial] [rendered]
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/portal-directives.d.ts (50,37): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/portal.d.ts (50,39): ',' expected.
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/portal.d.ts (92,23): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/portal.d.ts (95,46): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/dom-portal-outlet.d.ts (31,37): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/portal-directives.d.ts (14,40): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/portal.d.ts (50,41): Type parameter name cannot be 'any'
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/overlay/typings/overlay-ref.d.ts (40,23): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/material/dialog/typings/dialog-container.d.ts (55,37): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/material/tabs/typings/tab.d.ts (27,23): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/material/tabs/typings/tab-body.d.ts (44,15): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/src/app/resolver_events/app.module.ts (13,10): Module '"C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/material/material"' has no exported member 'MdProgressBarModule'.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-ng4@0.0.0 buildAll: `ng build --app main && ng build --app queryparams && ng build --app child && ng build --app guards && ng build --app outlets && ng build --app lazy && ng build --app resolver`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-ng4@0.0.0 buildAll script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\CISOW\AppData\Roaming\npm-cache\_logs\2018-02-02T09_46_16_349Z-debug.log
C:\2018\66\TUTORIALE\angular2typescript\Angular4\router-samples [master ≡ +4 ~1 -0 !]
λ ng s --port=7893
Your global Angular CLI version (1.7.0-beta.3) is greater than your local
version (1.6.7). The local Angular CLI version is used.
To disable this warning use "ng set --global warnings.versionMismatch=false".
** NG Live Development Server is listening on localhost:7893, open your browser on http://localhost:7893/ **
Date: 2018-02-02T09:47:22.673Z
Hash: 3f5058b17bd5577560fc
Time: 15196ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 28.8 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 613 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 34.2 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 7.06 MB [initial] [rendered]
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/portal-directives.d.ts (50,37): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/portal.d.ts (50,39): ',' expected.
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/portal.d.ts (92,23): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/portal.d.ts (95,46): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/dom-portal-outlet.d.ts (31,37): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/portal-directives.d.ts (14,40): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/portal/typings/portal.d.ts (50,41): Type parameter name cannot be 'any'
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/cdk/overlay/typings/overlay-ref.d.ts (40,23): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/material/dialog/typings/dialog-container.d.ts (55,37): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/material/tabs/typings/tab.d.ts (27,23): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/material/tabs/typings/tab-body.d.ts (44,15): Generic type 'TemplatePortal<C, any>' requires 2 type argument(s).
ERROR in C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/src/app/resolver_events/app.module.ts (13,10): Module '"C:/2018/66/TUTORIALE/angular2typescript/Angular4/router-samples/node_modules/@angular/material/material"' has no exported member 'MdProgressBarModule'.
webpack: Failed to compile.
## How to remedy this (fix my bug)?
Not really an error, but confusing for a beginner like me ;)
Line 19:
selector: "app-root",
according to the other examples
selector: "app",
Hi Webpack2 beta 24 is out with some breaking changes.
Did you try to use this release in your code?
Using Google Chrome I get following error
Failed to load file://Web/AngularWithTypescript/Chp1/main.ts: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
Please suggest.
I've tried to run this example from the book, and it failed. After that, I found your repository (thank you a lot by the way) and tried to run this time your code but got the same issue. I can go and read the rest of the book, but if it is possible I want also to run the simplest "hello world"... but I can't
I found simple error in your example code.
closing bracket is missing in
https://github.com/Farata/angular2typescript/blob/master/appendixa/forof.html#L19
Thank you for your nice book & have a good day!!
MDN input event say:
The DOM input event is fired synchronously when the value of an <input>, <select>, or <textarea> element is changed.
But in Chapter 5 P158, There is
"You may argue that you could implement the preceding example by handling the input event, which would be dispatched when the user finished entering the stock symbol and moved the focus out of the input field. This is true, but there are many scenarios where you’ll want an immediate response from the server, such as retrieving and filtering a data collection as the user types."
I liked this book so much so I wonder we could see an updated version of this book in the near future with stand alone components, Cypress and other newer changes
On page 404, it states:
Manually implement a module design pattern as an immediately initialized function
I believe, it should say "as an immediately invoked function".
Hey,
File:
Angular4/http-node-samples/client/src/app/restclientform/product.service.ts
Line 12: (solution)
return this.http.get(/api/products/${productID}
)
the original URL (without '/api/) doesn't fit the proxy spezification
Greetings
As the code show,the name of event should be same as @output property which is ”lastPrice“,but in following bold string :
“On the application level, the event handler for the last-price event is invoked to display the price quote that arrives with the event object”
The event which is named "lastPrice" is called "last-price" wrongly
seems that typings command is
typings install dt~es6-shim --save --global
When running npm run build
, no CSS is produced in dist/.
These files are in dist/:
The relevant logs are:
Asset Size Chunks Chunk Names
vendor.bundle.js.map 7.63 MB 0 [emitted] vendor
f4769f9bdb7466be65088239c12046d1.eot 20.1 kB [emitted]
448c34a56d699c29117adc64c43affeb.woff2 18 kB [emitted]
e18bbf611f2a2e43afc071aa2f4e1512.ttf 45.4 kB [emitted]
89889688147bd7575d6327160d64e760.svg 109 kB [emitted]
vendor.bundle.js 1.21 MB 0 [emitted] vendor
bundle.js 80.3 kB 1 [emitted] main
fa2772327f55d8198301fdb8bcfc8158.woff 23.4 kB [emitted]
bundle.js.map 397 kB 1 [emitted] main
bundle.js.gz 14.5 kB [emitted]
bundle.js.map.gz 65.8 kB [emitted]
vendor.bundle.js.gz 267 kB [emitted]
vendor.bundle.js.map.gz 1.51 MB [emitted]
index.html 315 bytes [emitted]
+ 717 hidden modules
and then
Condition always false [./~/style-loader/addStyles.js:24,0]
Dropping unreachable code [./~/style-loader/addStyles.js:25,0]
Condition always false [./~/style-loader!./~/css-loader!./~/bootstrap/dist/css/bootstrap.min.css:10,0]
Dropping unreachable code [./~/style-loader!./~/css-loader!./~/bootstrap/dist/css/bootstrap.min.css:12,0]
Side effects in initialization of unused variable update [./~/style-loader!./~/css-loader!./~/bootstrap/dist/css/bootstrap.min.css:7,0]
I would suggest naming chapters something like "chapter-01", "chapter-09", "chapter-10" to make it easier to read on the sort.
Or, add the name to the chapter: "ch01-name-of-chapter"
I'm pre-ordering the book as I'm jumping into Angular 2 having not touched code beyond Rails circa 2010.
In A.8.3,This code produces the following output:
Getting customers
Getting orders for undefined
["John Smith","Order 123"]
I think the result should be
Getting customers
["John Smith","Found the order 123 for undefined"]
I even can't find the sentence:"Getting orders for " in this book
Hi,
I'm getting this error on npm start
:
ERROR in ./~/bootstrap/dist/css/bootstrap.min.css
Module parse failed: F:\src\angular2typescript\chapter10\auction\client\node_modules\bootstrap\dist\css\bootstrap.min.css Unexpected token (5:83)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (5:83)
at Parser.pp.raise (F:\src\angular2typescript\chapter10\auction\client\node_modules\acorn\dist\acorn.js:920:13)
at Parser.pp.unexpected (F:\src\angular2typescript\chapter10\auction\client\node_modules\acorn\dist\acorn.js:1483:8)
at Parser.pp.semicolon (F:\src\angular2typescript\chapter10\auction\client\node_modules\acorn\dist\acorn.js:1462:73)
at Parser.pp.parseExpressionStatement (F:\src\angular2typescript\chapter10\auction\client\node_modules\acorn\dist\acorn.js:1976:8)
at Parser.pp.parseStatement (F:\src\angular2typescript\chapter10\auction\client\node_modules\acorn\dist\acorn.js:1754:188)
at Parser.pp.parseTopLevel (F:\src\angular2typescript\chapter10\auction\client\node_modules\acorn\dist\acorn.js:1648:21)
at Parser.parse (F:\src\angular2typescript\chapter10\auction\client\node_modules\acorn\dist\acorn.js:1616:17)
at Object.parse (F:\src\angular2typescript\chapter10\auction\client\node_modules\acorn\dist\acorn.js:882:44)
at Parser.parse (F:\src\angular2typescript\chapter10\auction\client\node_modules\webpack\lib\Parser.js:902:15)
at DependenciesBlock.<anonymous> (F:\src\angular2typescript\chapter10\auction\client\node_modules\webpack\lib\NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (F:\src\angular2typescript\chapter10\auction\client\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
at nextLoader (F:\src\angular2typescript\chapter10\auction\client\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
at F:\src\angular2typescript\chapter10\auction\client\node_modules\webpack-core\lib\NormalModuleMixin.js:259:5
at Storage.finished (F:\src\angular2typescript\chapter10\auction\client\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:38:16)
at F:\src\angular2typescript\chapter10\auction\client\node_modules\graceful-fs\graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:404:3)
@ ./src/vendor.ts 13:0-47
I've already tried various things that people suggested for similar situations, but to no avail so far. Could you kindly check if this needs a fix in the config?
Many thanks,
Mathias
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.