Как я игнорирую каталог в корне моего репозитория мерзавца, но включаю его далее вниз в дерево?

В дополнение к ответу cgTag:

Я бы рекомендовал установить значение по умолчанию также в ngOnChanges ловушке жизненного цикла.

export class MyComponent implements OnInit, AfterViewInit {
  // moved default value to static property, to prevent duplication
  private static defaultImgName: string = "img_one";

  @Input() public imgName: string = MyComponent.defaultImgName;  

  constructor() {
    // after compiling typescript to javascript,
    // imgName property will actually be populated here
  }

  ngOnChanges(values: SimpleChanges) {
    // please note, that ngOnChanges is not executed,
    // if component is initialized w/o any bindings

    // this will be executed on every change of imgName,
    // so if you need it to be checked only once - you can do that
    // with the method values.imgName.isFirstChange()
    if (values.imgName && values.imgName.currentValue === undefined) {
       this.imgName = MyComponent.defaultImgName;
    }
  }

  ngOnInit() {
    console.log("Inside ng on init");
  }

  ngAfterViewInit() {
    console.log("imgName value is: ${this.imgName}")
  }
}
42
задан fifi finance 23 April 2017 в 20:53
поделиться

1 ответ

Используйте продвижение /

  /file.x

, Который будет только соответствовать верхнему уровню file.x, но не каждый опускается, в "want/file.x", говорит.

66
ответ дан richq 26 November 2019 в 23:50
поделиться
Другие вопросы по тегам:

Похожие вопросы: