Created
October 24, 2022 14:49
-
-
Save mgechev/e37ceeb60ce486e7ad8b2672a3935b69 to your computer and use it in GitHub Desktop.
v15 blog post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bootstrapApplication(AppComponent, { | |
providers: [ | |
provideRouter(appRoutes), | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bootstrapApplication(AppComponent, { | |
providers: [ | |
{ | |
provide: DATE_PIPE_DEFAULT_OPTIONS, | |
useValue: { dateFormat: 'shortDate' } | |
} | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@use '@angular/material' as mat; | |
$theme: mat.define-light-theme(( | |
color: ( | |
primary: mat.define-palette(mat.$red-palette), | |
accent: mat.define-palette(mat.$blue-palette), | |
), | |
typography: mat.define-typography-config(), | |
density: -2, | |
)); | |
@include mat.all-component-themes($theme); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'mat-menu', | |
hostDirectives: [HasColor, { | |
directive: CdkMenu, | |
inputs: ['cdkMenuDisabled: disabled'], | |
outputs: ['cdkMenuClosed: closed'] | |
}] | |
}) | |
class MatMenu {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"builder": "@angular-devkit/build-angular:browser-esbuild" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const route = { | |
path: 'admin', | |
canActivate: [() => inject(LoginService).isLoggedIn()] | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgOptimizedImage } from '@angular/common'; | |
// Include it into the necessary NgModule | |
@NgModule({ | |
imports: [NgOptimizedImage], | |
}) | |
class AppModule {} | |
// ... or a standalone Component | |
@Component({ | |
standalone: true | |
imports: [NgOptimizedImage], | |
}) | |
class MyStandaloneComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
standalone: true, | |
template: '...' | |
}) | |
export default class LazyComponent { ... } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Routes} from '@angular/router'; | |
import {LazyComponent} from './lazy.component'; | |
export const lazyRoutes: Routes = [{path: '', component: LazyComponent}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {MatLegacyButtonModule} from '@angular/material/legacy-button'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mat-slider> | |
<input matSliderStartThumb> | |
<input matSliderEndThumb> | |
</mat-slider> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
path: 'lazy', | |
loadComponent: () => import('./lazy-file').then(m => m.LazyComponent), | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable({providedIn: 'root'}) | |
export class MyGuardWithDependency implements CanActivate { | |
constructor(private loginService: LoginService) {} | |
canActivate() { | |
return this.loginService.isLoggedIn(); | |
} | |
} | |
const route = { | |
path: 'somePath', | |
canActivate: [MyGuardWithDependency] | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"builder": "@angular-devkit/build-angular:browser" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"polyfills": [ | |
"zone.js" | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ERROR Error: Uncaught (in promise): Error | |
Error | |
at app.component.ts:18:11 | |
at fetch (async) | |
at (anonymous) (app.component.ts:4) | |
at request (app.component.ts:4) | |
at (anonymous) (app.component.ts:17) | |
at submit (app.component.ts:15) | |
at AppComponent_click_3_listener (app.component.html:4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Routes} from '@angular/router'; | |
export const appRoutes: Routes = [{ | |
path: 'lazy', | |
loadChildren: () => import('./lazy/lazy.routes').then(routes => routes.lazyRoutes), | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {bootstrapApplication} from '@angular/platform-browser'; | |
import {ImageGridComponent} from './image-grid'; | |
@Component({ | |
standalone: true, | |
selector: 'photo-gallery', | |
imports: [ImageGridComponent], | |
template: ` | |
... <image-grid [images]="imageList"></image-grid> | |
`, | |
}) | |
export class PhotoGalleryComponent { | |
// component logic | |
} | |
bootstrapApplication(PhotoAppComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ERROR Error: Uncaught (in promise): Error | |
Error | |
at app.component.ts:18:11 | |
at Generator.next (<anonymous>) | |
at asyncGeneratorStep (asyncToGenerator.js:3:1) | |
at _next (asyncToGenerator.js:25:1) | |
at _ZoneDelegate.invoke (zone.js:372:26) | |
at Object.onInvoke (core.mjs:26378:33) | |
at _ZoneDelegate.invoke (zone.js:371:52) | |
at Zone.run (zone.js:134:43) | |
at zone.js:1275:36 | |
at _ZoneDelegate.invokeTask (zone.js:406:31) | |
at resolvePromise (zone.js:1211:31) | |
at zone.js:1118:17 | |
at zone.js:1134:33 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
path: 'lazy', | |
loadComponent: () => import('./lazy-file'), | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment