Fudamentals Flashcards
What and where is the Angular.json file?
A json file at the root level of the Angular workspace, provides project specific and workspace configuration details.
Such as path details for styles, scripts and assets.
And config for build and development tools by the CLI (e.g. serve.
A per-project config section and a few workspace properties
What is the purpose of the package.json file?
Configures the npm package (node) dependencies that are available for all projects in the workspace
What are NPM packages?
A package in Node.js contains the files you need for a module.
What is Node.js?
Node.js is an open-source server environment.
Allows you to run JavaScript on the server
What is the function of package-lock.json file?
Provides version information for all packages installed into node_modules by the npm client
What is the function of package-lock.json?
Provides version information for all packages installed in node_modules by the npm client
What is the function of the node_modules?
NPM packages are installed here and is accessible to the entire workspace.
The dependencies here will be visible to all projects (if its workspace wide)
In terms of programming, how does Node.js perform?
Node.js runs single-threaded, non-blocking, asynchronous programming
What is NPM?
NPM is a package manager for Node.js packages (and can be used for modules as well)
It is installed with Node.js
Consists of three main components:
-the website
-the CLI (command line interface)
-the registry
What is the public NPM registry?
A database of JavaScript packages.
It is used by developers to contribute & distribute their packages to communities (or local to their organisation) and also install others.
How do you use NPM?
Can be run via CLI with commands in a terminal.
‘npm …’
What is NVM?
And what is it used for?
Node Version Manager, a tool for (surprise) managing Node versions on your device.
Different projects on your device might be using different NPM versions, so can be provide version compatibility
What does the index.html file do?
The common name for the default page shown for a website (if no other page is specified)
Appropriately named as it serves an index to the main pages of the site
What is bootstrapping?
Bootstrapping is the process of initialising or loading the Angular application
What are the main steps in Bootstrapping?
- Load the Index.html file as the starting point for the app
- Loads Angular and third-party libraries/applications
- Executes the main.ts file as the application entry point (or as defined in the angular.json file for that project)
- Calls the bootstrapModule function to load and execute the Root module (app.module.ts)
- Executes the Root Component/s (example: app.component.ts) as defined in the Root Module in the bootstrap array. Sometimes called the Entry Components (not to be confused with the deprecated way to bootstrap)
- Display the Root Module Template (if called in the index.html)
What does the main.ts file do?
The file acts as the main entry point of the application, which is defined in the angular.json file.
It creates the browser environment with
‘Import {platformBrowserDynamic} from ‘@angular/platform-browser-dynamic’
And calls the bootStrapModule function to tell the builder to bootstrap the app:
‘platformBrowserDynamic().boostrapModule(AppModule)’
What does the App.module.ts file do when the application first loads?
This is the default name for the file that will bootstrap the initial components.
It loads the components listed in the bootstrap array under the ‘providers’ array. And it will insert each one into the DOM
Each of those bootstrapped components is the base of its own tree of components.
Most applications only have one component tree and bootstrap single root
What is the root component?
The initial component bootstrapped by the app.module.ts when the application starts
And it is loaded into the DOM
What are Angular Modules?
Angular NgModules are different to JavaScript (ES2015) modules
But like JS modules they can import functionality from other modules and allow their functionality to be exported.
NgModules is a class marked by the @NgModule decorator.
Ng Modules are basically containers for components.
As Angular loads items in a hierarchical tree structure, a list of components can be loaded in with the initialisation of that module
Describe the structure of an Angular Module
A module will import the decorator class @NgModule from angular core and will have the decorator @NgModule ({…})
In which you have the following:
Declarations [ ]
Lists the component classes to be loaded in. As well as directives and pipes
Imports [ ]
Other modules to be loaded
Providers [ ]
Services are loaded in here and the bootstrap array
And then the export of the module along with any module specific functions.
What is an Angular Component
Each Component defines a class that contains the application data and logic and is associated with an HTML template that defines a view.
Components will often load child components into its view via the selectors, forming a tree structure relationship
Define the structure of a component
It will import the Component class from angular core and have the Component decorator @Component
The decorator defines the class as a component class and specifies its metadata.
In the decorator you have the following:
Selector:
The tag that other components (or in an html document) can use to reference this template. Which often build a view hierarchy
Template/TemplateUrl
Defines the component’s ‘host view’. This html is either put inline or as a relative path to a html file.
Providers
Like modules, can define an array of services that the component requires.
What might you use to delimit a multi-line literal string for a template in the @Component?
A Template literal.
Delimits the string literal with backticks
template: <div>Hello World</div>
<br>
What is Data-Binding in Angular?
A mechanism for coordinating parts of a template with parts of a component.
Essentially allow you to send values, properties or events between the DOM and the Component.
Typically placed in the html of the template
Can be a two-way binding (send either direction) depending on the binding