Angular 6 WebComponent变量

时间:2018-10-01 11:12:17

标签: angular angular6 web-component

我有一个正确制作的组件,我想在角度6中做Web组件。 但是,生成Web组件后,变量将停止工作。 例如,更改滑块的值不会更改[(ngModel)]="amountShare"

App.module.ts

import {BrowserModule} from '@angular/platform-browser';
import {Injector, NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {AppComponent} from './app.component';
import {SectionComponent} from './section/section.component';
import {createCustomElement} from '@angular/elements';
@NgModule({
    declarations: [
        AppComponent,
        SectionComponent
    ],
    imports: [
        BrowserModule,
        FormsModule
    ],
    entryComponents: [SectionComponent],
})
export class AppModule {
    constructor(private injector: Injector) {
    }

    ngDoBootstrap() {
        const customSection = createCustomElement(SectionComponent, {injector: this.injector});
        customElements.define('custom-section', customSection);
    }
}

section.component.tscodepen上的section.component.html

0 个答案:

没有答案