Skip to content

Instantly share code, notes, and snippets.

@michaelilyin
Last active May 19, 2020 08:20
Show Gist options
  • Save michaelilyin/0fae00c959ff771311d2d17e90a589cf to your computer and use it in GitHub Desktop.
Save michaelilyin/0fae00c959ff771311d2d17e90a589cf to your computer and use it in GitHub Desktop.
Find an issue and propose decision
<button (click)="config.expanded = !config.expanded">{{ config?.expanded ? 'Collapse' : 'Expand' }}</button>
<hrh-expandable-info [config]="config"></hrh-expandable-info>
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { ExpandableConfig } from '../expandable-info/expandable-info.component';
@Component({
selector: 'hrh-container',
templateUrl: './container.component.html',
styleUrls: ['./container.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ContainerComponent implements OnInit {
config: ExpandableConfig = {
title: 'Harry Potter',
description: 'The Boy Who Lived',
expanded: false
};
constructor() {}
ngOnInit(): void {}
}
<div class="title">{{ config?.title }}</div>
<div *ngIf="config?.expanded" class="description">{{ config?.description }}</div>
import { Component, OnInit, ChangeDetectionStrategy, Input } from '@angular/core';
export interface ExpandableConfig {
title: string;
description: string;
expanded: boolean;
}
@Component({
selector: 'hrh-expandable-info',
templateUrl: './expandable-info.component.html',
styleUrls: ['./expandable-info.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ExpandableInfoComponent implements OnInit {
@Input() config?: ExpandableConfig;
constructor() {}
ngOnInit(): void {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment