小编geo*_*-un的帖子

Angular 4:没有找到组件工厂,你是否将它添加到@ NgModule.entryComponents?

我在webpack中使用Angular 4模板,当我尝试使用组件时会出现此错误(ConfirmComponent):

找不到ConfirmComponent的组件工厂.你有没有把它添加到@ NgModule.entryComponents?

组件在app.module.server.ts中声明

@NgModule({
  bootstrap: [ AppComponent ],
  imports: [
    // ...
  ],
  entryComponents: [
    ConfirmComponent,
  ],
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)

我还有app.module.browser.ts和app.module.shared.ts

如何解决这个问题.谢谢

angular angular-webpack-starter

231
推荐指数
13
解决办法
23万
查看次数

Angular2材质对话框有问题 - 您是否将其添加到@ NgModule.entryComponents?

我试图按照https://material.angular.io/components/component/dialog上的文档但我不明白为什么它有以下问题?

我在我的组件上添加了以下内容:

@Component({
  selector: 'dialog-result-example-dialog',
  templateUrl: './dialog-result-example-dialog.html',
})
export class DialogResultExampleDialog {
  constructor(public dialogRef: MdDialogRef<DialogResultExampleDialog>) {}
}
Run Code Online (Sandbox Code Playgroud)

在我的模块中,我补充道

import { HomeComponent,DialogResultExampleDialog } from './home/home.component';

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
    DashboardComponent,
    HomeComponent,
    DialogResultExampleDialog
  ],

// ...
Run Code Online (Sandbox Code Playgroud)

但我得到这个错误....

EXCEPTION: Error in ./HomeComponent class HomeComponent - inline template:53:0 caused by: No component factory found for DialogResultExampleDialog. Did you add it to @NgModule.entryComponents?
    ErrorHandler.handleError @ error_handler.js:50
    next @ application_ref.js:346
    schedulerFn @ async.js:91
    SafeSubscriber.__tryOrUnsub @ Subscriber.js:223
    SafeSubscriber.next @ Subscriber.js:172
    Subscriber._next @ Subscriber.js:125
    Subscriber.next …
Run Code Online (Sandbox Code Playgroud)

angular-material angular

222
推荐指数
4
解决办法
13万
查看次数

Java性能:true与Boolean.TRUE

哪个在性能和高效内存使用方面更好?

Boolean isItTrue(arg){ 
    return Boolean.TRUE;
}

boolean isItTrue(arg){
    return Boolean.TRUE
}

Boolean isItTrue(arg){
    return true;
}

boolean isItTrue(arg){
    return true;
}
Run Code Online (Sandbox Code Playgroud)

使用基本类型应该更快更容易,但另一方面,当使用对静态对象的引用时,不会创建新值.或者可能是它在编译器级别上进行了优化,true并且false被静态对象的引用所取代以节省内存?

java performance boolean memory-footprint

26
推荐指数
4
解决办法
2万
查看次数

docker-compose down和Ctrl + C之间的区别

假设您运行了一个多容器Docker应用程序,该应用程序由一个数据库容器和一个应用程序容器组成。以下两种关闭它的方法有什么区别:

第一种方法
1.打开一个终端,然后使用启动应用程序docker-compose up
2.使用关闭应用程序Ctrl + C

第二种方法
1.打开一个终端,然后使用启动应用程序docker-compose up
2.打开第二个终端,然后使用关闭应用程序docker-compose down

以我的理解,这两种方法应该完全相同。但是,在使用第二种方法时,我通常会在应用程序的日志中看到一些异常,即它已经关闭时无法连接到数据库,否则我看不到。

推荐的方法是什么?

docker docker-compose

7
推荐指数
1
解决办法
1452
查看次数

打字稿:花括号作为函数参数

在检查Alfresco ADF的内容元数据组件时,我偶然发现了以下打字稿功能,但我无法理解它:

private saveNode({ changed: nodeBody }): Observable<Node> {
  return this.nodesApiService.updateNode(this.node.id, nodeBody);
}
Run Code Online (Sandbox Code Playgroud)

我不明白的是{ changed: nodeBody }.

根据这个这个答案,大括号用于表示对象文字,作为使用键/值对作为函数参数的一种方式。但在这里它被用作参数。如果这创建了一个对象,在我的理解中,这意味着它changed是其属性的名称,并nodeBody指的是属性值。但是这个对象分配给了哪个变量,如何在方法体中引用它?

更让我困惑的是,只有nodeBody在 return 语句中使用。那么为什么不立即将其用作单个参数呢?

这种输入形式的好处或用例是什么?

typescript angular

7
推荐指数
1
解决办法
2379
查看次数

带有html的angular-tree-component样式节点

我正在使用angular 5和angular-tree-component https://github.com/500tech/angular-tree-component。我想为一个节点设置与其他节点不同的样式

import { Component, ViewChild} from '@angular/core';
import { TreeComponent } from 'angular-tree-component';

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

  @ViewChild('myTree')
  private tree: TreeComponent;

  nodes = [
    {
      id: 1,
      name: 'root1',
      children: [
        { id: 2, name: '<b>child1</b>' },
        { id: 3, name: 'child2' }
      ]
    }
  ];
}
Run Code Online (Sandbox Code Playgroud)

因此,问题在于,b标签要通过与角度进行消毒\lt b \gt \lt b \gt

如何以实用的角度生成HTML?

angular

2
推荐指数
1
解决办法
2510
查看次数