reboottime / angular-playbook Goto Github PK
View Code? Open in Web Editor NEWCrash angular for interview, now it's a repository works as a Angular playbook.
Crash angular for interview, now it's a repository works as a Angular playbook.
This article discusses Angular directives, covering:
References
Below is a speculative explanation of how the Material UI button functions, focusing on the mat-raised-button directive, without referring to the actual source code.
import { Directive, ElementRef, Renderer2, OnInit } from '@angular/core';
@Directive({
selector: '[mat-raised-button]'
})
export class MatRaisedButtonDirective implements OnInit {
constructor(private el: ElementRef, private renderer: Renderer2) {}
ngOnInit() {
// Add Material Design specific classes
this.renderer.addClass(this.el.nativeElement, 'mat-button');
this.renderer.addClass(this.el.nativeElement, 'mat-raised-button');
// Add any additional styles or attributes necessary for the raised effect
this.renderer.setStyle(this.el.nativeElement, 'box-shadow', '0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12)');
// ... other styles or event bindings
}
}
@NgModule({
declarations: [
MatRaisedButtonDirective,
// ... other components and directives
],
// ...
})
export class MaterialModule { }
<button mat-raised-button>Click Me</button>
This article talks about Angular Applications' state management solutions, primarily covered two means:
This article talks about Unit testing in Angular applications.
References
This article talks about reactive form in Angular. Bellow are the main points:
At the end of this article, I also listed some FAQs that you can't find on Angular official doc.
This article collects some common used Angular libraries.
This note is a essential list of creating angular app SPA, content covered are
--configuration
parameter, for example, build your code for staging
environment. ng build --configuration=staging
This article discusses the routing essentials of large Angular applications, with content organized in two parts:
Part I: URL Design for Single Page Applications
Part II: Common Routing Requirements
References
This article intends to guide a newbie to be familiar with angular material ui. content covered are highly similar what angular material ui official doc.
This article discusses the code style I endorse for Angular applications.
References
This article collections code snippets about some common usage scenarios in Rxjs.
Bellow are the list
This article attempts to seize Rxjs essentials in a short time. The content covers two parts:
As RxJS declares itself as a library for reactive programming using Observables, this article starts with understanding reactive programming essentials.
About: This article navigates Angular state management using Ngrx.
Ngrx is a strongly opinionated global and local state management solution for angular application.
Status: Draft
This article talks about building a toast tool using angular material ui such that user can programmatically notify user
By Asking GPT 4, so this is not my effort.
Angular Material
NGX-Bootstrap
PrimeNG
Clarity Design System
NG-ZORRO
Kendo UI for Angular
Onsen UI
Vaadin
Nebular
When building single page applications, the common needs are
Authorization
headerGiven my background in developing React SPAs and positive experiences with React Testing Libraries and Playwright, this playbook proposes the following solutions for testing Angular apps.
used only when you want to inject some services
ngOnChanges: This hook is called whenever one or more data-bound input properties of a directive or a component changes. It receives a SimpleChanges
object containing the previous and current values of the input properties.
When to use: Use this hook when you need to react to changes in input properties.
ngOnInit: This hook is called after Angular has initialized all data-bound properties of a directive. It is a good place to perform initialization logic for your component.
When to use: Use this hook when you need to set up the initial state of your component or perform one-time initialization tasks.
ngDoCheck: This hook is called during every change detection cycle. It allows you to perform your own custom change detection logic.
When to use: Use this hook when you need to implement custom change detection or perform more granular change detection.
ngAfterContentInit: This hook is called after Angular has projected external content (e.g., content passed between component tags).
When to use: Use this hook when you need to perform initialization logic that relies on content projection.
ngAfterContentChecked: This hook is called after Angular has checked the content projected into the component.
When to use: Use this hook when you need to perform additional checks or logic after Angular has checked the content.
ngAfterViewInit: This hook is called after Angular has initialized the component's views and child views.
When to use: Use this hook when you need to perform initialization logic that relies on the view or its child views.
ngAfterViewChecked: This hook is called after Angular has checked the component's views and child views.
When to use: Use this hook when you need to perform additional checks or logic after Angular has checked the views.
ngOnDestroy: This hook is called just before Angular destroys the component. It is a good place to clean up resources, unsubscribe from observables, etc.
When to use: Use this hook when you need to clean up resources or perform any necessary cleanup before a component is destroyed.
ngOnInit: Use this hook to fetch initial data from a server or set up initial state based on input properties.
ngOnChanges: Use this hook to react to changes in input properties. For example, if you have a component that displays user details, you can use this hook to update the display whenever the user data changes.
ngAfterViewInit: Use this hook when you need to interact with the DOM or perform operations that require the view to be fully initialized. For example, if you need to work with a specific element in the template, this is the appropriate hook.
ngOnDestroy: Use this hook to clean up resources like subscriptions to observables or event listeners to prevent memory leaks.
Remember, the choice of which lifecycle hook to use depends on the specific requirements of your application and component. Use the appropriate hooks to manage the state and behavior of your components effectively.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.