// Custom Theming for Angular Material // For more information: https://material.angular.io/guide/theming @use'@angular/material' as mat; // Plus imports for other components in your app.
// Include the common styles for Angular Material. We include this here so that you only // have to load a single css file for Angular Material in your app. // Be sure that you only ever include this mixin once! @include mat.core();
// Define the palettes for your theme using the Material Design palettes available in palette.scss // (imported above). For each palette, you can optionally specify a default, lighter, and darker // hue. Available color palettes: https://material.io/design/color/ $my-app-primary: mat.define-palette(mat.$teal-palette); $my-app-accent: mat.define-palette(mat.$teal-palette, A200, A100, A400);
// The warn palette is optional (defaults to red). $my-app-warn: mat.define-palette(mat.$red-palette);
// Create the theme object. A theme consists of configurations for individual // theming systems such as "color" or "typography". $my-app-theme: mat.define-light-theme(( color: ( primary: $my-app-primary, accent: $my-app-accent, warn: $my-app-warn, ), typography: mat.define-typography-config(), density: 0 ));
// Include theme styles for core and each component used in your app. // Alternatively, you can import and @include the theme mixins for each component // that you are using. @include mat.all-component-themes($my-app-theme);
Put the theme file in angular.json or project.json(for Nx monorepo), Architect -> build -> options -> styles
Posted onEdited onInangular Symbols count in article: 227Reading time ≈1 mins.
The @Output decorator is used to define an output property in a component. The output property is used to emit events from the component to the parent component. The @Output decorator is used in conjunction with the EventEmitter class to emit events.
The connection between child component and parent component is established by binding the updateParentName output property of the child component to the updateName method of the parent component.
Posted onEdited onInangular Symbols count in article: 465Reading time ≈2 mins.
Over the past three releases, Angular team introduced a lot of new features and improvements, Angular 18 focused on polishing the previous work and graduating many of the new APIs from experimental to stable. another exciting feature is zoneless change detection - still in experimental phase. Here is the content table:
Zoneless Change Detection
angular.dev is the new home for angular developers
Stable features: Material 3, deferrable views, built-in control flows
SSR improvements: i18n hydration support, better debugging, hydration support in Angular Material.
From Angular 17, you can use the first format with some extra configuration in ChildComponent. In this way Angular will automatically convert the flag attribute to a boolean value.
You can use the following cli command to transit your app to standalone.
1
ng generate @angular/core:standalone
and you’ll see the following options in terminal, use the arrow key to select the options.
1 2 3 4
? Choose the type of migration: (Use arrow keys) > Convert all components, directives and pipes to standalone Remove unnecessary NgModule classes Bootstrap the application using standalone APIs
The code is trying to get the user info, if the user is active, it will return the user info, otherwise, it will return undefined. But does it make sense to return undefined in the else branch? In JavaScript, if a function does not return anything, it implicitly returns undefined. So, the above code can be refactored to:
1 2 3 4 5
constgetUserInfo(user: User) { if (user.isActive) { return user.info; } }
The first code snippet is xxx.then().catch() while the second code snippet is xxx.catch().then(), since promise.catch also return a promise, so handler in the second code snippet will always be executed. But in the first code snippet, the handler will not be executed.