Chapter 4

  1. The MEAN stack consists of four major components:
    • MongoDB: MongoDB is a NoSQL database that became the de facto standard in building database support into client/server applications with Node. There are other database options available, but MongoDB is a very popular choice.
    • Express: Express wraps up a log of the complications of working with server-side code under Node and makes it easier to use. For instance, if we want to deal with HTTP requests, Express makes this trivial, as opposed to writing the equivalent Node code.
    • Angular: Angular is the client-side framework that makes creating powerful web frontends easier.
    • Node: Node (or Node.js) is the runtime environment for our application on the server.
  2. We supply a prefix to make our component unique. Suppose we had a component that we wanted to call label; obviously, this will clash with the built-in HTML label. To avoid this clash, our component selector would be atp-label. Since HTML controls never use hyphens, we guarantee that we aren't going to collide with existing control selectors.
  3. To start our Angular application, we run the following command in the top-level Angular folder:
ng serve --open
  1. In the same way that our own language is broken down and structured into words and punctuation, we can break visual elements down into structures such as color and depth. As an example, the language tells us what colors mean, so if we see a button with one color on one screen in our application, it should have the same underlying usage across other screens in our application; we wouldn't use a green button to signify OK on one dialog and then Cancel on another. The idea behind a design language is that elements should be consistent. So, if we create our application as a Material application, it should be familiar to someone using Gmail (for instance).
  2. We create services using the following command:
ng generate service <<servicename>>

This can be shortened to the following:

ng g s <<servicename>>
  1. Whenever a request comes into our server, we need to determine how to handle the request the best, which means that we have to route it to the appropriate piece of functionality to handle the request. Express routing is the mechanism we use to accomplish this.
  2. RxJS implements the observer pattern. This pattern has an object (known as the subject) that keeps track of an array of dependencies (known as the observers) and notifies them of interesting behaviors, such as state changes.
  1. CORS stands for Cross-Origin Request Sharing. With CORS, we let known external locations have access to restricted operations on our site. In our code, since Angular is running from a different site to our web server (localhost:4200, as opposed to localhost:3000), we need to enable CORS support to post, otherwise we won't return anything when we make requests from Angular.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.31.73