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 { | |
provideHttpClient, | |
withJsonpSupport, | |
withXsrfConfiguration | |
} from '@angular/common/http'; | |
import { bootstrapApplication } from '@angular/platform-browser'; | |
bootstrapApplication(AppComponent, { | |
providers: [ | |
provideHttpClient( |
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 userControl = this.fb.control('', Validators.required); | |
const groupControl = this.fb.control('', Validators.required); | |
const $case = this.assignee?.get('$case'); | |
$case?.valueChanges.pipe(startWith($case.value)).subscribe(($case) => { | |
clearOneOf(this.assignee); | |
this.assignee.addControl( | |
$case, | |
$case === 'userId' ? userControl : groupControl |
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({ | |
template: ` | |
<form [formGroup]="form"> | |
<ng-container formGroupName="assignee"> | |
<div> | |
<input | |
type="radio" | |
name="$case" | |
formControlName="$case" | |
value="userId" |
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({ | |
template: ` | |
<form #f="ngForm"> | |
<ng-container ngModelGroup="assignee"> | |
<div> | |
<input | |
type="radio" | |
name="$case" | |
[ngModel]="assigneeCase" | |
value="userId" |
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
interface Task { | |
name: string; | |
assignee: | |
| { $case: 'userId'; userId: string } | |
| { $case: 'userGroupId'; userGroupId: string }; | |
} |
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
// users.routes.ts | |
import { SvgIconRegistry } from '@ngneat/svg-icon'; | |
import { addGroupIcon, removeGroupIcon } from '@app/svg'; | |
const ICONS_INIT = attachInitEffect(() => { | |
inject(SvgIconRegistry).register([ | |
addGroupIcon, | |
removeGroupIcon | |
]) | |
}) |
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: [ | |
OFFLINE_INIT | |
] | |
}) |
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
export const OFFLINE_INIT = attachInitEffect(() => { | |
const toast = inject(ToastService); | |
const window = inject(WINDOW); | |
window.addEventListener('offline', () => { | |
toast.warning('There is no internet connection', { | |
duration: 10_000, | |
}) | |
}) | |
}) |
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 { ENVIRONMENT_INITIALIZER, Provider } from '@angular/core'; | |
export function attachInitEffect(fn: VoidFunction): Provider { | |
return { | |
multi: true, | |
provide: ENVIRONMENT_INITIALIZER, | |
useValue: fn, | |
}; | |
} |
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
AppComponent.ɵfac = function AppComponent_Factory(t) { | |
return new (t || AppComponent)( | |
_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵɵdirectiveInject"](FOO), | |
_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵɵdirectiveInject"](BAR, 8), | |
_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵɵdirectiveInject"]( | |
_angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpClient | |
), | |
... | |
); | |
}; |