Search code examples
htmlangularangular-componentsangular4-forms

Show elements from base component in derived component Angular 4/5


@Component({
  selector: 'app-test-base',
  templateUrl: '<button (click)="someMethod()">Button on Base Component</button>>',
  styleUrls: ['./test-base.component.css']
})

@Component({
  selector: 'app-derived',
  templateUrl: './derived.component.html',
  styleUrls: ['./derived.component.css']
})

export class derivedComponent extends baseComponent implements OnInit {...}

Is possible to inject this button on derived HTML component?


Solution

  • If i understood what you have/want.. You can call like so:

    <app-test-base></app-test-base>
    

    on your derived.component.html page, and your app-test-base components gets started up on your derived component. Do note that the someMethod method should be declared on the app-test-base and all the other logic for interacting with that page.. You can also pass Inputs and receive Outputs from this kind of behaviour.. but thats another story :3