import { Component , Input , NgModule } from '@angular/core' ; import { StackblitzWriter } from './stackblitz-writer' ; import { MatButtonModule } from '@angular/material/button' ; import { MatIconModule } from '@angular/material/icon' ; import { MatTooltipModule } from '@angular/material/tooltip' ; import { ExampleType } from '../example-viewer/example-viewer.component' ; @ Component ( { selector : 'formly-stackblitz-button' , templateUrl : './stackblitz-button.html' , providers : [ StackblitzWriter ] , } ) export class StackblitzButton { stackblitzForm ; @ Input ( ) type : string ; @ Input ( ) set example ( exampleData ) { this . stackblitzForm = this . stackblitzWriter . constructStackblitzForm ( this . type , exampleData ) ; } constructor ( private stackblitzWriter ) { } openStackblitz ( ) { document . body . appendChild ( this . stackblitzForm ) ; this . stackblitzForm . submit ( ) ; document . body . removeChild ( this . stackblitzForm ) ; } } @ NgModule ( { imports : [ MatTooltipModule , MatButtonModule , MatIconModule ] , exports : [ StackblitzButton ] , declarations : [ StackblitzButton ] , providers : [ StackblitzWriter ] , } ) export class StackblitzButtonModule { }