- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
当我想使用以下包版本在 AOT 中编译我当前的项目时,我遇到了问题:
my webpack and tsconfig.json configuration can be find here
我遇到了一些与 private
相关的问题/protected
在模板上使用的范围和一些提取参数提供给一些并不真正需要它的函数(例如不在 EventBinding 上使用的 $event)。
现在我有以下列表,但我找不到我的问题在哪里:
/path/to/app/header/main-header/main-header.component.html(85,7): : Directive TableOfContentComponent, Expected 0 arguments, but got 1. (1,1): : Directive TableOfContentComponent, Expected 0 arguments, but got 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
};
还有我的TableOfContentComponent
不包含任何 @Input
属性(property)。
@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 tableOfContentService: TableOfContentService,
private deviceService: DeviceService,
private elemRef: ElementRef) {
super();
this.toc = this.tableOfContentService.tableOfContent;
}
}
/path/to/app/header/main-header/hamburger-menu/hamburger-menu.component.html(125,5): : Directive SliderComponent, Expected 0 arguments, but got 1. (1,1): : Directive SliderComponent, Expected 0 arguments, but got 1.
我的 hamburger-menu.component.html
接近上面提供的代码:
<ps-slider-component [template]="slidable" [countItems]="associatedDocuments.length">
<ng-template #slidable>
<ul class="clearfix">
<li class="ps-hmt-associated-item-wrapper pull-left slider-item"
*ngFor="let document of associatedDocuments">
<a href="{{ document.link }}" target="_blank" class="btn-nostyle">
<div class="ps-hmt-image">
<img src="{{ document.images.thumbnail }}" alt="">
</div>
<p class="ps-hmt-title slider-text"
[matTooltip]="isArticleView ? null : document.title"
[matTooltipPosition]="'above'"
[matTooltipClass]="['ps-mat-tooltip', 'ps-mat-tooltip-doc']"
>
{{ document.title }}
</p>
</a>
</li>
</ul>
</ng-template>
</ps-slider-component>
// On ts side
associatedDocuments: Array<AssociatedDocumentModel>;
@ViewChild('slidable') slidable: ElementRef;
还有我的SliderComponent
看起来像:
export class SliderComponent extends UnsubscribeHelper implements OnInit, OnChanges {
@Input() template: ElementRef;
@Input() countItems: number;
@Input() resetSlide ?: null;
@Input() fixedHeight?: null;
@Input() isVariableWidth?: null;
@Input() isBookmarks?: null;
@Input() hasSkeleton?: boolean = false;
/path/to/app/header/main-header/medias/dialogs/image-dialog.component.html(34,5): : Directive CarouselComponent, Expected 0 arguments, but got 1. (1,1): : Directive CarouselComponent, Expected 0 arguments, but got 1.
非常接近上一个,我认为问题是一样的。
/path/to/app/document/page/page.component.html(7,9): : Directive InfinityPageScrollComponent, Expected 0 arguments, but got 1. (1,1): : Directive InfinityPageScrollComponent, Expected 0 arguments, but got 1.
这里我们没有关于 InfinityPageScrollComponent
的任何输入标签是这样调用的 <ps-infinity-page-scroll></ps-infinity-page-scroll>
准确地说,当我在我的 webpack 上禁用 AOT 时,一切都像 charm 一样工作。
我已尝试在 AoT Do's and Don'ts 上找到解决方案没有任何结果。
我还注意到我是否禁用了 fullTemplateTypeCheck
我面临大约 18 000 个错误,其中一些隐含的任何类型和更奇怪的、未定义的属性用于我在构造函数上声明的服务。
--- 编辑 1:为抽象类提供代码:UnsubscribeHelper
---
export abstract class HeaderItemAbstract extends UnsubscribeHelper implements AfterViewInit {
public toggleItem: string = 'out';
public ANIMATION_DURATION = slideUpAndDownAnimationDuration;
constructor() {
super();
}
// [Some other method]
/**
* Self animate after loading on DOM
*/
ngAfterViewInit()
{
// Wait next to to avoid error :
// ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked
setTimeout(() => {
this.toggleAnimation();
},100);
}
}
抽象类的代码UnsubscribeHelper
:
export abstract class UnsubscribeHelper implements OnDestroy {
subscriptions: Subscription[] = [];
ngOnDestroy() {
this.subscriptions.forEach(sub => sub.unsubscribe());
}
addSubscription(subscription: Subscription) {
this.subscriptions.push(subscription);
}
}
最佳答案
好吧,我在这里准备了一个minimal, complete, and verifiable example
我注意到 @HostListner
缺少一个参数
问题示例如下:
@HostListener('window:resize', ['$event'])
onResize(): void {
}
只需删除 '$event'
就可以了。
总而言之,这两个选项可以正常工作:
// When you need the Event variable, you can use following syntax.
@HostListener('window:resize', ['$event'])
onResize($event: Event): void {
}
// When you do not need the Event variable, you can use following syntax.
@HostListener('window:resize')
onResize(): void {
}
感谢@trichetriche 的帮助。
关于angular - AOT - Angular 6 - 指令 SomeComponent,预期 0 个参数,但得到 1 个。对于自制组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50405930/
我正在尝试从 Unity 发布到我的 iPhone 4s。构建成功,但我继续收到此消息: “在 aot-only 模式下运行时无法加载 AOT 模块‘Assembly-CSharp’,因为依赖项无法找
在听说了这么多有关 Angular AOT 模式的信息后,我想尝试一下。因此,我们将应用程序迁移到 Angular v4.1.2,并进行了所有必要的更改。当我尝试使用我的 webpack 配置文件中的
我有一个 C# 项目,我需要将其编译为 native 二进制文件。我在这里读过: http://www.mono-project.com/AOT Mono 可以将程序集预编译为两个选项之一: --ao
我搜索了很多关于这种伟大语言的信息,并在此页面上找到了自己 https://github.com/dart-lang/sdk/wiki/Snapshots但它没有回答一些问题: 快照和 AOT 有什么
我知道什么是字节码检测。它只是在运行时更改 .class 文件字节码,这似乎从 JDK 1.5 开始可用。但是,据说是在类加载期间而不是运行时。 现在我的问题是,什么是 AOT 或提前检测?相反的程序
我正在为我的应用程序构建一个插件系统。我读到任何人都可以反编译 .class 文件,因此我不得不使用 Ahead-Of-Time 编译器(对吗?)。问题是我需要动态加载一些插件类。现在,我正在将所有
我的问题是 Angular 模块之一无法在 Safari 浏览器中正常工作。 我有以下代码: @NgModule({ bootstrap: [ AppComponent ], impo
我在这里问是因为我无法在网上找到完整的文档。示例 here太简单了。我有一个包含多个组件和一些模块的应用程序。用ngc编译后,我有很多错误。我发现修复它们的方法是使用相对路径。因此,我在所有组件中都使
在使用 webpack 进行 AOT 构建后,bundle 将每个组件模板包含两次,使得 bundle 比需要的大得多,因为模板作为字符串包含在内,UglifyJS 无法缩小。 我希望组件模板被排除为
我正在尝试使用 ngc 编译 angular 2.4.4: Error: Error encountered resolving symbol values statically. Expressio
当我这样做时,有什么原因(我可以解决): ngc -p tsconfig.aot.json 作为回应,它要求: 姓名: ngc 似乎忽略了我的 tsconfig.aot.json。 这可能是什么原因?
我正在开发一个 Angular 7 应用程序,除了加载问题外它工作正常,在研究中我发现我应该使用 AOT 构建而不是 JIT 或正常构建,由于应用程序规模巨大,我无法进行 aot 构建,它正在返回堆我
我在 Dynamics AX 2012 中有一个 AOT 查询,它由 HcmWorker 和 HcmEmployment 表(等等)组成。我的问题是,当我创建报告(不是 SSRS)或以其他方式使用此查
有谁知道在使用带有 AOT 编译的 Angular CLI 时如何获得更详细的错误堆栈跟踪?使用 JIT 编译运行时,我的应用程序没有问题,但是当我运行 ng build --aot 时,我得到的只是
我想查询 AOT 以查看是否存在使用 X++ 的表名。谁能指出我正确的方向或提供一些示例代码来做到这一点? 如果表存在并提供名称 (str tableName),则返回 true;否则,返回false
我有一个 Angular 5 应用程序,当我在测试模式下运行时没有问题,也就是说,当我使用 ng serve 命令在本地运行应用程序时。但是,当我在生产模式下部署应用程序时,即通过命令ng build
语境 我正在创建一个 Angular 应用程序的桌面版本,为此我正在使用 Electron 。 打开主窗口非常简单: win = new BrowserWindow({ width: 1280
我有一个看起来像这样的错误处理程序: @Injectable() export class GlobalErrorHandler implements ErrorHandler { construct
当我尝试构建启用了 AOT 选项的 Android 应用程序时,收到以下错误消息。 Invalid command line switch for "aapt.exe". VersionCode is
我在我的 Angular 2 应用程序中使用 Highcharts 和 Kendo Charts,当我尝试运行 AOT 编译时,它会抛出类似的错误 Cannot Import Module 或 Hom
我是一名优秀的程序员,十分优秀!