install angular cli globally
uninstall angular cli globally
npm install -g @angular/cli
npm uninstall -g @angular/cli
npm cache clean –force
Apply class “host-inactive” on the HTMLElement hosting the component/directive and onClick, set the class to “host-active”.
Inside decorator:-
host: {
‘[class]’: ‘classState()’,
‘(click)’: ‘toggleInactive($event)’
}
Inside class:-
protected classState = signal(“host-inactive”);
toggleInactive(event: Event) {
if (this.classState() === “host-inactive”)
this.classState.set(“host-active”);
}
What does min-height: 100vh mean?
Why should you apply this style to the root component of your application?
100vh means “Make sure the root component is layed out at least as tall as the screen, irrespective of the height of the parent element”.
https://copilot.microsoft.com/shares/VPcezYmajCoCKKmZFProJ
difference between min-height: 100vh; and min-height: 100%;
min-height: 100vh; means minimum height is 100% of the viewport height.
min-height: 100%; means minimum height is 100% of the parent element’s height.
If you use min-height: 100% without setting height on the parent, your layout might collapse to fit the content.
Lazy load the children routes of ‘auth’ feature:
‘auth/login’
‘auth/signup’
so that, auth bundle is not loaded into DOM unless user visits ‘/auth’ route
and
signup bundle is not loaded into DOM if user visits ‘/auth/login’ route.
Inside auth.routes.ts:
export const AUTH_ROUTES: Routes = [
{
path: ‘login’,
loadComponent: () => import(‘./components/login/login’).then(m => m.CtLoginComponent),
title: ‘CoTask | Sign In’
},
];
Inside app.routes.ts:
export const routes: Routes = [
{
path: ‘auth’,
// Lazy load the feature routes
loadChildren: () => import(‘./features/auth/auth.routes’).then(m => m.AUTH_ROUTES),
},
];
BEM style class names of
1. login component
2. button inside login component
3. disabled button inside login component
Does order of routes matter in Routes array?
If yes, what should be order of
* auth
* /
* ** (wildcard)
Yes, Angular router processes routes sequentially, from top to bottom, and uses the first path match it finds.
1. auth
2. /
3. **
In my mind questions for HLD
What will be output?
const user = { name: “Sahil” };
user.name = “Copilot”;
console.log(user.name);
“Copilot”
If const is used with an object or array, the reference is fixed, but the contents can still be mutated.
What will be output?
class User {
readonly id: number;
constructor(id: number) {
this.id = id;
}
}
const u = new User(1);
u.id = 2;
console.log(u.id);
Error.
Cannot mutate a readonly property of the class.
const for immutable variables and references (box).
readonly for immutable properties of classes (contents of the box)
When to use protected and when to use private?
Angular templates as privileged subclasses of your component. They can call protected methods in event bindings (like a child calling a parent’s protected method), but they can’t read or bind to protected properties directly
fb.nonNullable.group()
versus
fb.group()
Using nonNullable eliminates the need for null checks in your code.
Manually trigger update to ensure all validations run on a form, especially the cross-field ones.
this.signupForm.markAllAsTouched();
Get value of email control from the formgroup defined by
fg =this.fb.nonNullable.group({
email: [’’],
password: [’’],
});
this.fg.controls.email.value
print errors of password form control.
console.log(this.loginFormGroup.controls.password.errors);
Difference between<a href="/auth/signup"></a>
and<a [routerLink]="['/auth/signup']"></a>
difference between
1. justify-content: center;
and
2. align-items: center;