Skip to content

Instantly share code, notes, and snippets.

View rexar1988's full-sized avatar

Denis rexar1988

  • @Ovidien
  • Ukraine
View GitHub Profile
@rexar1988
rexar1988 / .eslintrc.json
Created October 20, 2021 08:56
Angular ESLint with NgRx
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
@rexar1988
rexar1988 / func-compose.js
Last active February 13, 2021 13:12
JS Function Compose
function compose(...functions) {
return argument => functions.reduceRight((acc, current) => current(acc), argument);
}
function pipe(...functions) {
return argument => functions.reduce((acc, current) => current(acc), argument);
}
const users = [
{
@rexar1988
rexar1988 / ng-template-context.ts
Created August 1, 2020 21:33
ng-template with context
<div class="template-content">
<ng-container [ngTemplateOutlet]="contact" [ngTemplateOutletContext]="context"></ng-container>
</div>
import '...';
@Component({
selector: 'app-ng-template',
templateUrl: './ng-template.component.html',
styleUrls: ['./ng-template.component.scss']
})
export class NgTempalateComponent implements OnInit {
context = {
myFirstName: 'John Doe',
@rexar1988
rexar1988 / ng-template.component.html
Created August 1, 2020 16:36
ng-template with context
<ng-container [ngTemplateOutlet]="contact" [ngTemplateOutletContext]="context"></ng-container>
@rexar1988
rexar1988 / ng-template.ts
Last active August 1, 2020 11:59
Variable in ng-template
<ng-template let-firstName="myFirstName" let-greeting="greeting">
<h2>Contact Template</h2>
<p>Hello, I am {{ firstName }}!</p>
<button (click)="greeting(firstName)">Show first name</button>
</ng-template>
@rexar1988
rexar1988 / some-component.html
Created August 1, 2020 11:50
Inserting ng-template
<ng-template #contact>
<h2>Contact Template</h2>
<p>Hello, I am contact template!</p>
</ng-template>
<div class="template-content">
<ng-container [ngTemplateOutlet]="contact"></ng-container>
</div>
<div class="template-content">
@rexar1988
rexar1988 / ng-template.ts
Created August 1, 2020 11:41
Using ng-template
<ng-template>
<h2>Hello! I am Template!</h2>
</ng-template>
@rexar1988
rexar1988 / node-type-list.page.ts
Created July 30, 2020 21:55
ViewContainerRef in NodeTypeListComponent
@Component({
selector: 'app-node-type-list',
templateUrl: './node-type-list.page.html',
styleUrls: ['./node-type-list.page.scss']
})
export class NodeTypeListPage implements OnInit {
constructor(private viewContainerRef: ViewContainerRef) { }
// Some code...
}
@rexar1988
rexar1988 / angular.component.ts
Last active July 30, 2020 17:29
ViewContainerRef example
// Внедрение в компонент
// this.viewContainerRef это ссылка на HTML-шаблон компонента
constructor(private viewContainerRef: ViewContainerRef) { }
// Внедрение в директиву
// this.viewContainerRef это ссылка на HTML-элемент директивы,
// который можно получить с помощью свойства this.templateRef
constructor(private templateRef: TemplateRef<ElementRef>,
private viewContainerRef: ViewContainerRef) { }