小编Yan*_*git的帖子

AOT - Angular 6 - 指令SomeComponent,预期0个参数,但得到1.对于自制组件

当我想在AOT中使用以下包版本编译我当前的项目时,我遇到了问题:

  • @ ngtools/@的WebPack 6.0.3
  • @ angular @ latest(6.0.2)
  • Webpack@4.0.0

我的webpack和tsconfig.json配置可以在这里找到

我面临一些与模板上使用的private/ protectedscope 有关的问题,并且一些提取参数给了一些并不真正需要它的函数(Exemple $ event,它们不用于EventBinding).

现在我有以下列表,我找不到我的问题:

/path/to/app/header/main-header/main-header.component.html(85,7)::指令TableOfContentComponent,期望0参数,但得到1.(1,1)::指令TableOfContentComponent,预期0争论,但得到1.

我的main-header.component.html文件包含:// main-header.component.html

// main-header.component.ts
@ViewChildren('headerItems') public headerItems: QueryList<HeaderItemAbstract>;
mainMenuStates = {
    hamburger: false,
    bookmarks: false,
    search: false,
    toc: false,
    medias: false,
    article: false,
    language: false    
};
Run Code Online (Sandbox Code Playgroud)

而且我TableOfContentComponent不包含任何@Input财产.

@Component({
    selector: 'ps-table-of-content-template',
    templateUrl: './table-of-content.component.html',
    animations: [slideUpAndDownAnimation]
})
export class TableOfContentComponent extends HeaderItemAbstract implements OnInit {

    toc: TableOfContentModel[];

    devices: DevicesModel;

    tocContentHeight: number;
    tocContentMargin: number;
    menuHeight: string;


    constructor(private …
Run Code Online (Sandbox Code Playgroud)

webpack angular angular-aot ngtools

17
推荐指数
2
解决办法
8106
查看次数

同一项目的角度AOT和JIT

在angular5上,我尝试对我的大多数模块/组件进行相同的项目AOT编译......但我有一部分需要进行JIT编译.

对于第二部分,HTML来自Ajax请求并包含一些必须由angular编译的组件标记.要管理这部分,我使用看起来像这样的指令:

export class ArticleLiveDirective implements OnInit, OnChanges, OnDestroy {

    // [...]    

    constructor(
        private container: ViewContainerRef,
        private compiler: Compiler
    ) { }

    // [...]

    private addHtmlComponent(template: string, properties: any = {}) {
        this.container.clear();
        //Force always rootDomElement.
        const divTag = document.createElement('div');
        divTag.setAttribute('id',this.currentId);
        divTag.innerHTML = template;
        template = divTag.outerHTML;

        // We create dynamic component with injected template
        @Component({ template })
        class ArticleLIveComponent implements OnInit, OnChanges, OnDestroy {
            constructor(
                private articleService: ArticleService
            ) {}
            ngOnInit() {}
            ngOnChanges(changes: SimpleChanges) {}
            ngOnDestroy() {}
            goToPage($event: Event, …
Run Code Online (Sandbox Code Playgroud)

jit aot angular angular-aot angular5

9
推荐指数
1
解决办法
1903
查看次数

标签 统计

angular ×2

angular-aot ×2

angular5 ×1

aot ×1

jit ×1

ngtools ×1

webpack ×1