Skip to content

Instantly share code, notes, and snippets.

View arturovt's full-sized avatar
🎯

Artur arturovt

🎯
View GitHub Profile
export class ArticleComponent {
article$: Observable<Article>;
constructor(
http: HttpClient,
route: ActivatedRoute,
@Inject(PLATFORM_ID) platformId: string,
meta: Meta,
transferState: TransferState,
) {
// This will be used on the client-side
@Injectable({ providedIn: 'root' })
export class ArticleService {
constructor(private transferState: TransferState) {}
getArticle(id: string): Observable<Article> {
const key = makeStateKey<Article>(`article:${id}`);
const article = this.transferState.get(key, null!);
return of(article);
}
if (isPlatformServer(platformId)) {
// Do some server-side stuff...
}
Vue.component('lazy', () => import('./lazy.component'));
import {
Component,
ChangeDetectionStrategy,
ViewChild,
ViewContainerRef,
ComponentFactoryResolver,
Injector
} from '@angular/core';
@Component({
import {
Component,
ɵrenderComponent as renderComponent,
Injector,
ɵLifecycleHooksFeature as LifecycleHooksFeature,
ɵmarkDirty as markDirty
} from '@angular/core';
@Component({
selector: 'app-root',
import { Component, OnInit, AfterViewInit } from '@angular/core';
@Component({
selector: 'app-button',
template: `
<button>{{ text }}</button>
`
})
export class ButtonComponent implements OnInit, AfterViewInit {
public text: string = null;
import {
Component,
ɵrenderComponent as renderComponent,
Injector,
ɵLifecycleHooksFeature as LifecycleHooksFeature
} from '@angular/core';
@Component({
selector: 'app-root',
template: `
import { Component, OnInit, AfterViewInit } from '@angular/core';
@Component({
selector: 'app-button',
template: `
<button>Click me</button>
`
})
export class ButtonComponent implements OnInit, AfterViewInit {
public ngOnInit(): void {
import { Component, ɵrenderComponent as renderComponent, Injector } from '@angular/core';
@Component({
selector: 'app-root',
template: `
<app-button></app-button>
`
})
export class AppComponent {
constructor(injector: Injector) {