- import { Component, Input, OnChanges, SimpleChange } from '@angular/core';
- @Component({
- selector: 'app-version-child',
- template: `
- <h3>Version {{major}}.{{minor}}</h3>
- <h4>Change log:</h4>
- <ul>
- <li *ngFor="let change of changeLog">{{change}}</li>
- </ul>
- `
- })
- export class VersionChildComponent implements OnChanges {
- @Input() major: number;
- @Input() minor: number;
- changeLog: string[] = [];
- ngOnChanges(changes: {[propKey: string]: SimpleChange}) {
- let log: string[] = [];
- for (let propName in changes) {
- let changedProp = changes[propName];
- let to = JSON.stringify(changedProp.currentValue);
- if (changedProp.isFirstChange()) {
- log.push(`Initial value of ${propName} set to ${to}`);
- } else {
- let from = JSON.stringify(changedProp.previousValue);
- log.push(`${propName} changed from ${from} to ${to}`);
- }
- }
- this.changeLog.push(log.join(', '));
- }
- }
Intercept input property changes with ngOnChanges()
Đăng ký:
Đăng Nhận xét (Atom)
StaticImage
import React , { useEffect , useRef } from "react" import { StaticImage } from "gatsby-plugin-image" impor...
-
letsencrypt "Certbot doesn't know how to automatically configure the web server on this system" (repusic.com) sudo yum inst...
-
Modify File Permissions with chmod | Linode Modify File Permissions with chmod The chmod command allows users to change read and write per...
-
https://www.cloudflare.com/learning/dns/dns-records/dns-a-record/ The "A" stands for "address" and this is the most fun...
Không có nhận xét nào:
Đăng nhận xét