Angular 2 Flashcards
4 key building blocks of angular 2 apps
Components
Directives
Routers
Services
Component
- Encapsulates the template, data, and behavior of a view (view component)
- Every app will have AT LEAST root component
- Are reusable
- Typescript/JavaScript class
- Do not need to reference the DOM
- Is bound to element
Service
- Provide specific functionality not directly related to views
- Injected into components as dependencies
- Any logic not related to ‘view’
- Any non UI logic
- ex. talking to backend APIs
- Data access, logging, business logic, configuration
Router
- Only responsible for navigation
- Defines navigation paths
- Maps URL-like paths to views instead of pages
Directive
- To modify DOM elements and/or extend their behavior
- keywords added to DOM elements
ng new
- Creates workspace and initial application
- CLI installs necessary npm packages
- creates skeleton
What is Angular?
A platform and framework for building single-page client applications using HTMl and TypeScript
NgModules
- a class @NgModule
- takes a metadata object that describes how to compile a component’s template and how to create an injector at runtime
- Help organize related things together
Views
- Sets of screen elements that Angular can choose amongh and modify according to program login and data
- arranged hierarchically
decorators
- Used by module, component and service classes
- functions that modify JavaScript classes
- Angular defines some that attach specific kinds of metadata to classes (tells system what those classes mean and how they should work)
AppModule (root module)
- Present in every Angular app
- provides bootstrap mechanism
workspace
- contains the files for one or more projects
project
- set of files that comprise as standalone application or shareable library
attribute directive
changes the appearance of behavior of a DOM element
ng generate directive DIRECTIVE_NAME
instantiates the directive to your src/app
ng serve
starts server, runs app
pipe operator |
transform strings, currency amounts, dates, and other data for display
simple functions you can use in template expressions to accept an input value and return a transformed value
[(ngModel)]
two-way binding
dependency
services or objects that a class needs to perform its function
provider
something that can create or deliver a service
provider
something that can create or deliver a service