Angular Commands
Angular Commands
-----------------------------------------------------------------------------------
------------------------------------------------------------------
install boostrap
1.npm install bootstrap
/* styles.css or styles.scss */
2.@import 'bootstrap/dist/css/bootstrap.min.css';
use tostify
/* styles.css or styles.scss */
@import '../node_modules/ngx-toastr/toastr.css'; /* Adjust the path based on your
project structure */
-----------------------------------------------------------------------------------
--------------------------------------------
In Angular, data binding refers to the process of connecting application data (in
the component) to the view (the template) and synchronizing
data between the view and the component. Angular provides four types of data
binding mechanisms, which allow communication between the component and the
template in different ways. These include:
5. single
3. **Event Binding** allows you to capture user actions in the view and respond by
executing methods in the component. You can pass `$event` to the method to get
information about the event that triggered it.
4. **Two-way Data Binding** combines property and event binding to allow seamless
synchronization of user input with the component state. It is essential for
handling forms, as it ensures that user input is always in sync with the component
model.
5 . single
These types of data binding enable Angular applications to manage and display data
efficiently, maintaining synchronization between the user interface and the
business logic layer in a declarative manner.
-----------------------------------------------------------------------------------
---------------------------------------------------------
communication b/w the parent to child component and it's vice-versa (using the
@Input() and @Output())
Parent Component
-----------------
| |
| parentData | ---> (property binding) ---> Child Component
| | |
----------------- |
| @Input() childData
|
(Emits Event)
|
v
EventEmitter
|
v
(event binding)
|
Parent Component (Listening) |
----------------- |
| | |
| receivedData | <--- (event emitted) <--- Child Component
| |
-----------------
-----------------------------------------------------------------------------------
----------------------------------------------------------
directives
- component directive
- structural directive (*ngFor="" , *ngIf="")
- attribute directive ([ngClass]="", [ngStyle]="{}")
-----------------------------------------------------------------------------------
------------------------------------------------------------
Data Binding: One-way and two-way binding
-----------------------------------------------------------------------------------
---------------------------------------------------------
control flow
@if @else @else if @switch
-----------------------------------------------------------------------------------
---------------------------------------------------------
pipe
-----------------------------------------------------------------------------------
-------------------------------------------------------
Template Form using ngModel
need to create form in .html file
steps to implement
0. need to import the FormsModule to use the ngModel
1. create the object with all the field
2. bind properties with input elements with ngModel
-----------------------------------------------------------------
ng s --port:8989
ng g c(component) componentname
ng g s(service) servicename
ng g p(pipe) pipename
----------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------
component(template+css) -> service (will contain the business logic and the
api calls )
-----------------------------------------------------------------------------------
---------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------------------------------------------------