Friday, May 17, 2024
Angular Basics
Intro
• package.json
• (list
of dependencies)
• package-lock.json
• (details
list of that dependencies)
• angular.json
• (map
everything here: assets, scripts etc)
• tsconfig.json
• (typescript
configuration file)
• polyfills.ts
• (compatibility
file)
Components
• Modules
must be declared in the imports
• Components
must be declared in the declarations
• Standalone
components are not dependent in any modules and it must be declared in imports
Routing
• Basic
Routing
• Routes – for mapping path
& component
• routerLink – navigate to
different routes
• router-outlet– for displaying
matched route
• Child
routing
• Activated
Route (const routeId = route.snapshot.paramMap.get(‘id’);)
• Module
Routing
• const
routes : Routes
• Lazy
Loading
Directives
• Add
additional behavior to elements
• Components
works as a directive
• Attribute
Directive
ngClass (Binding
Classes)
ngStyle (Binding
Styles, Only accept objects s = {})
ngModel (Two Way
Binding)
• Structural
Directive
*ngIf
*ngFor
*ngSwitch
Services
• Defined
with @Injectable
• All
are in observable format and without subscribe it won’t
work (Rxjs feature)
FormType
• TDF
–
handle in html file
• ngForm
• Reactive
–
handle in ts file
• FormGroup
Guard
• used
to control access in particular route
• canActivate
• canActivateChild
• canDeactivate
Interceptor
• Used
for token login
Rxjs
• Observable and Operators
Monday, March 4, 2024
Reactive Programming
Pending: Initial state, neither fulfilled nor rejected.
Fulfilled: The operation completed successfully.
Rejected: The operation failed.
from
function to convert various data sources, including Promises, into Observables. toPromise()
operator to convert an Observable into a Promise.Saturday, June 10, 2023
Run React Globally
If you have problems running create-react-app in text editors but the package is installed globally. So here is the SOLUTION-------------
Open PowerShell as an administrator. You can do this by right-clicking on the Windows Start button and selecting "Windows PowerShell (Admin)".
In the PowerShell window, run the following command to check the current execution policy:
powershellGet-ExecutionPolicy
The output will be one of the following:
- Restricted: This means that script execution is disabled. You need to change it to a more permissive policy.
- AllSigned or RemoteSigned: These policies allow script execution but require digitally signed scripts. If you encounter this, you can skip changing the execution policy and try using the
npx create-react-app
command instead ofcreate-react-app
.
To change the execution policy to allow script execution, run the following command:
powershellSet-ExecutionPolicy Unrestricted
You will be prompted to confirm the change. Type
Y
and press Enter.After changing the execution policy, you should be able to use the
create-react-app
command without encountering the "running scripts is disabled" error.Once you've finished using
create-react-app
, it's recommended to set the execution policy back to a more secure value. Run the following command:powershellSet-ExecutionPolicy Restricted
By following these steps, you should be able to resolve the script execution error and use create-react-app globally in any text editor.
Sunday, May 7, 2023
Logical Shifting COA