Skip to content

Instantly share code, notes, and snippets.

View zzpzaf's full-sized avatar

Panos zzpzaf

View GitHub Profile
@zzpzaf
zzpzaf / test1.component.ts
Created July 15, 2024 07:34
signals-data-sharing-test1.component-class-2
import { Component, ElementRef, ViewChild, effect } from '@angular/core';
import { IMsg, ShareDataService } from '../share-data.service';
@Component({
selector: 'test2',
standalone: true,
imports: [],
templateUrl: './test2.component.html',
styleUrl: './test2.component.scss'
})
@zzpzaf
zzpzaf / share-data.service.ts
Last active July 15, 2024 07:24
signals-data-sharing-service-2
import { Injectable, signal } from '@angular/core';
export interface IMsg {
sender: string;
msg: string;
}
@zzpzaf
zzpzaf / app.component.ts
Created July 15, 2024 06:52
signals-data-sharing-app.component-class-1
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { Test1Component } from './test1/test1.component';
import { Test2Component } from './test2/test2.component';
@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet, Test1Component, Test2Component],
templateUrl: './app.component.html',
@zzpzaf
zzpzaf / test1.component.scss
Created July 14, 2024 08:55
signals-data-sharing-test1.component-stylesheet-1
.tcenter {
text-align: center;
}
.my-container {
display: flex;
flex-direction: column;
align-items: center;
border-radius: 8px;
@zzpzaf
zzpzaf / test1.component.html
Created July 14, 2024 08:53
signals-data-sharing-test1.component-template-1
<!-- <p>test1 works!</p> -->
<div class="my-container" (keydown)="onKeyEnter($event)">
<br />
<h2>This is the {{ compName }}</h2>
<input type="text" placeholder="Enter message" #input />
<br />
<button type="button" (click)="onClick(input.value)">Send</button>
<br />
<div class="inner-row">
@zzpzaf
zzpzaf / test1.component.ts
Created July 14, 2024 08:50
signals-data-sharing-test1.component-class-1
import { Component, ElementRef, ViewChild, effect } from '@angular/core';
import { IMsg, ShareDataService } from '../share-data.service';
@Component({
selector: 'test1',
standalone: true,
imports: [],
templateUrl: './test1.component.html',
styleUrl: './test1.component.scss'
})
@zzpzaf
zzpzaf / share-data.service.ts
Created July 14, 2024 08:45
signals-data-sharing-service-1
import { Injectable, signal } from '@angular/core';
export interface IMsg {
sender: string;
msg: string;
}
@zzpzaf
zzpzaf / form.component.html
Created April 18, 2024 14:45
dynamicform1_HTML-template-of-the-FormComponent_c11
<form
class="q2container"
[formGroup]="dynFormGroup"
(ngSubmit)="onFormSubmit($event)"
>
<div *ngFor="let field of formFields">
<div [ngSwitch]="field.controlType">
<div *ngSwitchCase="'input'">
<ng-template [ngIf]="field.inputType === 'radio'" [ngIfElse]="other">
<label *ngFor="let option of field.options">
@zzpzaf
zzpzaf / form.component.ts
Last active April 18, 2024 14:42
dynamicform1_FormComponent_c11
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { ItemsFormFieldsService } from '../items-form-fields.service';
import { Subscription } from 'rxjs';
import { IFormField } from '../dataObjects/IFormField';
@Component({
selector: 'dyn-form',
templateUrl: './form.component.html',
styleUrls: ['./form.component.scss'],
@zzpzaf
zzpzaf / request-data.component.ts
Created April 18, 2024 14:40
dynamicform1_RequestDataComponent_c11
import { Component } from '@angular/core';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { ItemsFormFieldsService } from '../items-form-fields.service';
import { Subscription } from 'rxjs';
@Component({
selector: 'app-request-data',
templateUrl: './request-data.component.html',
styleUrls: ['./request-data.component.scss']