Set default attribute values to every component

Hello,

Is it possible to set a default value to an attribute of a component ? Let’s say I want the ion-button to always be shape=round, is there anyway to do it without repeating this on every component?

i think (but maybe i’m wrong) you can declare a new component, your html file should be something like


   <ion-button [shape]='this.shape' [otherProp_one]='this.otherProp_one'></ion-button> (and all the other props you need)
 
import { Component, Input } from '@angular/core';

@Component({
  selector: 'ion-mybutton',
  templateUrl: './mybutton.component.html',
  styleUrls: ['./mybutton.component.scss'],
})
export class MyButtonComponent {

  @Input()
  shape: string = 'round';
  otherProp_one: string = '';
  otherProp_two: string = '';

   ...
  otherProp_ten: string = '';
  constructor() {
  }


}

and when you call it from your app just do like this:


<ion-mybutton shape='round'></ion-mybutton>

don’t forget to add this to your component module (from where you are using the new button)

import { MyButtonComponent } from '../../components/mybutton/mybutton.component.module';

@NgModule({
  imports: [
    CommonModule,
    ...
    ...
    MyButtonComponent,
  ],
  declarations: [YourPage]
})
export class YourPageModule {}