Extending ion-button


#1

I’d like to extend ion-button component to add some methods on a custom component of my own. So I did:

import {Component, ElementRef, Renderer} from '@angular/core';
import {Button, Config} from "ionic-angular";

@Component({
  selector: '[search-button]',
  templateUrl: 'search-button.component.html',
})
export class SearchButtonComponent extends Button {
  constructor(ionButton: string, config: Config, elementRef: ElementRef, renderer: Renderer) {
    super(ionButton, config, elementRef, renderer);
  }
}

But this is giving me a ERROR Error: Uncaught (in promise): Error: No provider for String! error.

What’s the good way of extending ionic components?


#2

Hi, @HugoHeneault

Can you try this…!

import {Component, ElementRef, Renderer} from '@angular/core';
import {Button, Config} from "ionic-angular";
@Component({
  selector: '[search-button]',
  templateUrl: 'search-button.component.html',
  providers:[Button,Config]
})
export class SearchButtonComponent extends Button {
  constructor(ionButton: string, config: Config, elementRef: ElementRef, renderer: Renderer) {
    super(ionButton, config, elementRef, renderer);
  }

Thanks