Skip to content

Instantly share code, notes, and snippets.

View cgatian's full-sized avatar
🏠
Working from home

Chaz Gatian cgatian

🏠
Working from home
View GitHub Profile
<div *ngFor="let userName of usersName$ | async">
{{ userName }}
</div>
import { Component } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { UsersGQL } from '../generated/types.graphql-gen';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
query Users {
users {
data {
name
}
}
}
@cgatian
cgatian / codegen.yml
Last active September 6, 2019 17:50
GraphQL Code Generator near-operation-file-preset
overwrite: true
schema: "schema.graphql"
documents: "src/**/*.graphql"
generates:
src/generated/types.graphql-gen.ts:
plugins:
- "typescript"
src/generated:
preset: near-operation-file
presetConfig:
@Component({
selector: 'my-app',
template: `
<ng-template cdkPortal #testTemplate="cdkPortal" let-name>
<div>User {{ name }} </div>
</ng-template>`,
})
export class AppComponent implements OnInit {
@ViewChild('testTemplate') testTemplatePortal: TemplatePortal<any>;
@Component({
selector: 'my-app',
template: `
<ng-template #testTemplate let-name>
<div>User {{ name }} </div>
</ng-template>`,
})
export class AppComponent implements OnInit {
@ViewChild('testTemplate') testTemplate: TemplateRef<any>;
private portalHost: DomPortalHost;
@Component({
selector: 'my-app',
template: `
<ng-template #testTemplate let-name>
<div>User {{ name }} </div>
</ng-template>`
})
export class AppComponent implements OnInit {
private componentRef;
@Component({
selector: 'app-test',
template: `
<ng-content [cdkPortalHost]="_portalInstance"></ng-content>
<ng-template cdkPortal #cartCount>
<div>Hello World</div>
</ng-template>
`
})
export class TestComponent implements OnInit {
@Component({
selector: 'app-test',
template: `
<ng-content [cdkPortalHost]="_portalInstance"></ng-content>
`
})
export class TestComponent implements OnInit {
_portalInstance: Portal<any>;
constructor() { }
@cgatian
cgatian / app.component.ts
Last active October 24, 2017 01:13
app component using portals
import { DomPortalHost, Portal, ComponentPortal } from '@angular/cdk/portal';
@Component({
selector: 'my-app',
template: '',
})
export class AppComponent implements OnInit {
private portalHost: DomPortalHost;
private portal: ComponentPortal<HeaderComponent>;