framework Flashcards
to export (make it public available) a module:
thatfile.js
export default{ foo:’hello’ }
to import a module:
thisfile.js:
import thatfile from ‘./thatfile’
console.log(b.foo);
Problems with ES2015 Modules
Duplicate Modules
Circular Dependency
Harder to manage overall
Angular Modules
not a replacement for ES2015 Modules
groups modules by feature
Angular Module in the right way
A module is imported once and then all the connected modules has its content available
it is a common practice to organice our modules in forlders
The name of the file is the name of the module along with the “.module.ts” string
A module is a type of
Class
import NgModule module and add the decorator
to declare the class as a module
Import BrowserModule
to tell Angular to run the app in a browser enviroment
A module allow us to wrapp many dependencies in to one module/file
so that this could be easily imported into others modules
Component
Reusable custom HTML tag with custom behaviour
A component renders
into a tag inner the DOM
Selector name should be
lowercase with only dashes to separte the words
‘app-root’ component
default component (tag or selector) to bootstrap an angular app
The template section is
valid html
A component also import a module and apply a decorator
to be consistent with the DOM
template-url:
instead of “template:” for inline html code
StyleUrls:[]
to add CSS files instead of “style:” to add embedded css rules
We declare (Import) the app component
that allow us to render components
We declare services (external data access)
like providers
We only declare the component module
to bootstrap the application
create a component through NG
ng generate component component_name
// it creates a folder, with a css, a html, test and an angular file with that name
// it registers it into the module file
to initialize the properties of a component
constructor(){}
To allow a parent component to modify the content of an specific property inner a component
// 1. Import “Input” from “@angular/core”
// 2. Add @Input() decorator before the declaration of out property