小编Pen*_*gyy的帖子

使用ElasticSearch API时出现错误“无活动连接”

在安装依赖项并运行node.js应用程序后,在node.js中使用ElasticSearch API会导致以下错误。

Elasticsearch ERROR: 2017-04-11T04:40:01Z
  Error: Request error, retrying
  POST http://localhost:9200/reports/report/_search?size=5000000 => connect ECONNREFUSED 127.0.0.1:9200
      at Log.error (/home/kartik/Documents/Project/Validus/validus_reports_server/node_modules/elasticsearch/src/lib/log.js:225:56)
      at checkRespForFailure (/home/kartik/Documents/Project/Validus/validus_reports_server/node_modules/elasticsearch/src/lib/transport.js:240:18)
      at HttpConnector.<anonymous> (/home/kartik/Documents/Project/Validus/validus_reports_server/node_modules/elasticsearch/src/lib/connectors/http.js:162:7)
      at ClientRequest.wrapper (/home/kartik/Documents/Project/Validus/validus_reports_server/node_modules/lodash/lodash.js:4968:19)
      at emitOne (events.js:77:13)
      at ClientRequest.emit (events.js:169:7)
      at Socket.socketErrorListener (_http_client.js:258:9)
      at emitOne (events.js:77:13)
      at Socket.emit (events.js:169:7)
      at emitErrorNT (net.js:1256:8)

{ [Error: No Living connections]
  message: 'No Living connections',
  body: undefined,
  status: undefined }
Run Code Online (Sandbox Code Playgroud)

帮我解决这个问题

node.js elasticsearch

5
推荐指数
0
解决办法
832
查看次数

Angular> = 4.3,httpClient.get params为空

我正在尝试将Http请求迁移到HttpClient请求.我能够迁移我的post查询但我在迁移get查询时遇到问题.当我这样做时,我的后端没有分别收到任何参数,它告诉我没有提供参数并且为空.

我做错什么了吗?

import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';

constructor(private httpClient: HttpClient) {}

findItems() {
   let params: HttpParams = new HttpParams();
   params.set('something', 'hello');

   this.httpClient.get<any[]>('http://localhost:3000/apath/', {params})
    .subscribe((results: any[]) => {
      console.log(results);
    }, (errorResponse: any) => {
       console.error(errorResponse);
    });
}
Run Code Online (Sandbox Code Playgroud)

任何的想法?

angular-http angular

4
推荐指数
1
解决办法
3182
查看次数

无法解析 BsModalService 的所有参数

我正在向我的 spfx angular 2 应用程序添加一个模态。我试图按照ngx-bootstrap-modal通过http://valor-software.com/ngx-bootstrap/#/modals。但我收到此错误:

Unhandled Promise rejection: Can't resolve all parameters for AppComponent: (?). ; Zone: <root> ; Task: 
Run Code Online (Sandbox Code Playgroud)

这是我的代码的样子:

包.json

{
  "name": "our-applications",
  "version": "0.0.1",
  "private": true,
  "engines": {
    "node": ">=0.10.0"
  },
  "dependencies": {
    "@angular/common": "^2.4.4",
    "@angular/compiler": "^2.4.4",
    "@angular/core": "^2.4.4",
    "@angular/forms": "^2.4.4",
    "@angular/http": "^2.4.4",
    "@angular/platform-browser": "^2.4.4",
    "@angular/platform-browser-dynamic": "^2.4.4",
    "@angular/router": "^3.4.4",
    "@angular/upgrade": "^2.4.4",
    "@microsoft/sp-client-base": "~1.0.0",
    "@microsoft/sp-client-preview": "~1.0.0",
    "@microsoft/sp-core-library": "~1.0.0",
    "@microsoft/sp-webpart-base": "~1.0.0",
    "@types/webpack-env": ">=1.12.1 <1.14.0",
    "angular2-modal": "^3.0.1",
    "ng2-modal": "0.0.25",
    "ngx-bootstrap": "^1.8.1",
    "reflect-metadata": "^0.1.9",
    "rxjs": "^5.0.3",
    "sp-pnp-js": …
Run Code Online (Sandbox Code Playgroud)

typescript bootstrap-modal angular

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

如何删除angular2反应形式的FormArray

我在从ReactiveForm删除FormArray时遇到问题。

我有以下代码:

ngOnInit() {
  this.survey = new FormGroup({
    surveyName: new FormControl(''),
    sections: new FormArray([
      this.initSection(), 
    ]), 
  });      
}

initSection(){
  return new FormGroup({
    sectionTitle : new FormControl(''),
    sectionDescription : new FormControl(''),
  });
}

addSection(){
  const control = <FormArray>this.survey.controls['sections'];
  control.push(this.initSection());
}
Run Code Online (Sandbox Code Playgroud)

现在要删除formControl surveyName我只是做

this.survey.removeControl('surveyName');
Run Code Online (Sandbox Code Playgroud)

上面的代码对于SurveyName工作正常。但是我可以使用什么删除表单数组部分。我想用键删除整个节对象。

angular

4
推荐指数
1
解决办法
6538
查看次数

Angular HttpInterceptor - 处理异步响应

我正在编写使用 IndexedDB 缓存数据的 Angular 应用程序。

每当应用程序即将对服务器进行特定的 http 调用时,我都想从 IndexedDB 检索此数据并丰富或替换来自服务器的响应。

问题是从 IndexedDB 检索数据是返回 Observable 的异步操作,我无法将修改后的数据返回给调用服务。

拦截器看起来像这样:

intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {

  return next.handle(req).map((event) => {
    if (event instanceof HttpResponse) {
      console.log("before cacheResponseProccess");

      const val: Observable<HttpEvent<any>> = this.angularCache.cacheResponseProccess(event);

      val.subscribe(x => {
        console.log('Return modified response is:');
        console.log(x);
        return x;
      });
    }
  }).catch((error, caught) => {
    return Observable.throw(error);
  });
}
Run Code Online (Sandbox Code Playgroud)

请参阅https://stackblitz.com/edit/angular-owqgb6上的问题示例

asynchronous indexeddb angular-http-interceptors angular

4
推荐指数
1
解决办法
1942
查看次数

角度材料:重置反应形式显示验证错误

我正在使用angular5 reactivemodule在我的应用程序中显示一个表单.我还使用了必需的验证器,随后将该字段设置为红色并向用户显示错误信息.

它按预期工作,但是当我使用重置表单时

this.form.reset()

表单显示了需要特定字段的验证错误.我还使用form.markAsPristine()或form.markAsUntouched()来使其工作,但在应用多个可能的对的组合后问题仍然存在.

example.html的

<form [formGroup]="checkForm" (ngSubmit)="submitForm()">
  <mat-form-field>
    <input matInput formControlName="name" placeholder="name" />
    <mat-error *ngIf="checkForm.get('name').errors?.required">
      Name is required.
    </mat-error>
  </mat-form-field>
  <mat-form-field>
    <input matInput formControlName="email" placeholder="email" />
    <mat-error *ngIf="checkForm.get('email').errors?.required">
      Name is required.
    </mat-error>
  </mat-form-field>
  <button [disabled]="checkForm.invalid" type="submit">add</button>
</form>
Run Code Online (Sandbox Code Playgroud)

example.ts

checkForm  = this.formBuilder.group({
  'name': ['', Validators.required],
  'email': ['', Validators.required]
});

submitForm() {
   this.checkForm.reset();
   // this.checkForm.markAsPristine();
   this.checkForm.markAsUntouched();      
}
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏.

reset angular angular-reactive-forms

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

Angular Material 6.0.1树默认打开并展开/折叠全部

我正在我的项目中使用Angular Material Tree.是否可以默认打开树.

并且可以有一种方法一次扩展/折叠所有节点(例如,使用按钮)

https://material.angular.io/components/tree/overview

tree angular-material angular

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

Angular:在选择选项时选择在与ngModel一起使用时不起作用

我有一个对象数组(命名用户),它们将显示为选项dropdownlist.我有另一个对象列表(名为selectedUsers并保存在后端),用于初始化dropdownlist.

数组:

users = [
  {
    id: 2,
    name: 'name2'
  },{
    id: 2,
    name: 'name2'
  },{
    id: 3,
    name: 'name3'
  }
];

selectedUsers3 = [
  {
    id: 1,
    name: 'name1'
  },{
    id: 2,
    name: 'name2'
  }
];
Run Code Online (Sandbox Code Playgroud)

我现在面临一个有线的情况是,当我绑定Objectselect options通过[ngValue],并绑定功能[selected],将检查中是否存在当前选项selectedUsers.

我可以看到函数被检索,结果返回true/false作为例外,但选项保持未选中状态.

模板:

<select multiple [(ngModel)]="selectedUsers3">
  <option *ngFor="let user of users" [selected]="checkExist(user)" [ngValue]="user">{{user.name}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)

组件中的功能:

checkExist(user) {
  return this.selectedUsers3.findIndex(selUser => selUser.id === user.id) > …
Run Code Online (Sandbox Code Playgroud)

typescript angular

3
推荐指数
1
解决办法
3146
查看次数

为什么在android中使用CATEGORY_OPENABLE

在这里,我已经编写了来自画廊的图像选择器的代码,但是谁能告诉我setAction()和的卷是什么addCategory()

意图类文件中有很多“静态最终字符串”可用,我完全不知道在我的程序中使用这些 ACTION 和 CATEGORY 参数

public class ImagePicker extends BaseActivity implements View.OnClickListener {

  private final int PICK_FROM_GALLERY_REQUEST = 1;
  private ImageView pickedImage;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.onStart();
    setContentView(R.layout.activity_image_picker);
    pickedImage= (ImageView) findViewById(R.id.image);
    Button cameraButton= (Button) findViewById(R.id.pick_from_camera);
    Button galleryButton= (Button) findViewById(R.id.pick_from_gallery);
    cameraButton.setOnClickListener(this);
    galleryButton.setOnClickListener(this);
    setViewHeight(pickedImage);
  }

  private void setViewHeight(ImageView pickedImage) {
    DisplayMetrics displayMetrics=getResources().getDisplayMetrics();
    pickedImage.getLayoutParams().height=displayMetrics.heightPixels/2;
  }


  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode==PICK_FROM_GALLERY_REQUEST && resultCode==RESULT_OK && data!=null){
        InputStream stream …
Run Code Online (Sandbox Code Playgroud)

android-intent

3
推荐指数
1
解决办法
5419
查看次数

通过角度读取/写入电子中的本地json文件

我要创造getpostput在电子功能的访问本地JSON文件。

  1. 目前,我正在json-server这样做,但在运行电子项目之前,我每次都需要单独运行本地主机。

  2. 我使用了另一个名为 - 的库electron-json-storage。但我总是收到 fs 错误。

有没有办法解决这个问题,或者有没有其他有用的方法来做到这一点?

electron angular

3
推荐指数
1
解决办法
6459
查看次数