How can I pass props down in Angular 2+ like React?

前端 未结 2 1828
别跟我提以往
别跟我提以往 2021-02-13 02:48

In react I can arbitrarily pass props down like so:

function SomeComponent(props) {
  const {takeOutProp, ...restOfProps} = props;
  return 
2条回答
  •  不知归路
    2021-02-13 03:32

    Actually it is not the answer on your question but perhaps it helps you. You can add one custom directive with all params you need.

    import { Directive, ElementRef } from '@angular/core';
    
    @Directive({
      selector: '[defaultConfig]'
    })
    export class DefaultDropdownConfigDirective {
        constructor(el: ElementRef) {
           el.nativeElement.style.backgroundColor = 'yellow';
           // your default config
    
        }
    }
    
    
    

    For more details you can read this

提交回复
热议问题