Angular Notes
Angular Notes
app.module.ts ->
@Component
onInit - Lifecycle hook This runs after the component is mounte in the dom
data binding - {{}} - string interpolation add javascript code inside curly braces
Parent to child we pass the data through the selector and get the data from
@input() decorator through the attribute name
class and style binding is used to dynamically add css to our html elements
[class.text-red] = "bool"
[style.backgroundColor] = "expression"
angular directives is used for manuplating the dom elements, i.e attaching
behaviour to HTML dom, angular syntax which we write inside html
[(ngModel)] = "value"
[hidden]
Custom Directive is very similar to creating the Angular component. The custom
directive is created using the @Directive decorator to replace the @component
decorator.
Structural Directive
Angular pipes are used to transforming data into a particular format when we only
that data transformed in a template or in html view
Angular interface - it is used for type checking and we declare a blueprint wheer
all the variables are declared and its data types
RouterModule.forRoot([
{path: 'posts', component: DemoListComponent}
])
Data binding
String interpolation- controller to view -> mix the data with html
Property binding[] - controller to view ->
Event binding - send an event from view to component
two way binding [(ngModel)] - data flows from view to controller and vice versa
If we want to do routing from html we use routerLink and if from component we use
router.navigate()