小编Nil*_*dri的帖子

得到错误../node_modules/rxjs/Rx"'没有导出成员''

我正在从教程(https://angular.io/tutorial/toh-pt4#inject-message-service)学习新的角度.在添加服务后运行应用程序时我陷入了困境

../node_modules/rxjs/Rx"'没有''的导出成员'.

    hero.service.ts
---------------------


import { Injectable } from '@angular/core';

// import { Observable, of } from 'rxjs';
import { Observable, of } from 'rxjs/Observable';

import { Hero } from './hero';
import { HEROES } from './mock-heroes';
import { MessageService } from './message.service';

@Injectable()

export class HeroService {

  constructor(private messageService: MessageService) { }

  getHeroes(): Observable<Hero[]> {
    // TODO: send the message _after_ fetching the heroes
    this.messageService.add('HeroService: fetched heroes');
    return of(HEROES);
  }
}
Run Code Online (Sandbox Code Playgroud)

我的Angular版本和相关信息是

Angular CLI: 1.7.4
Node: 6.14.1 …
Run Code Online (Sandbox Code Playgroud)

rxjs angular angular5

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

在 LazyFrame 上使用 py-polars sink_parquet 方法时出现问题

在 LazyFrame 上使用 sink_parquet 时出现以下错误。早些时候,我使用.collect()的输出scan_parquet()将结果转换为 DataFrame,但不幸的是它不适用于大于 RAM 的数据集。这是我收到的错误 -

PanicException: sink_parquet not yet supported in standard engine. Use 'collect().write_parquet()'
Run Code Online (Sandbox Code Playgroud)

在 LazyFrame 上添加一些过滤器和连接条件后,我尝试将 LazyFrame(scan_parquet 的输出)写入本地文件。错误似乎来自以下位置 -

https://github.com/pola-rs/polars/blob/master/py-polars/polars/internals/lazyframe/frame.py#L1235(Python

https://github.com/pola-rs/polars/blob/master/polars/polars-lazy/src/physical_plan/planner/lp.rs#L154(Rust)。

我已尝试更新到最新版本0.15.16 0.16.1 但此问题仍然存在。

示例代码:

pl.scan_parquet("path/to/file1.parquet")
.select([
    pl.col("col2"),
    pl.col("col2").apply( lambda x : ...)
    .alias("splited_levels"),
    ..followed by more columns and .alias()
])
.join(<another lazyframe>,on="some key",how="inner")
.filter(...)
.filter(..)
..followed by some more filters
.sink_parquet("path/to/result2.parquet")
Run Code Online (Sandbox Code Playgroud)

parquet 文件应写入本地系统中。相反,我收到以下错误 -

PanicException: sink_parquet not yet supported in standard engine. Use 'collect().write_parquet()'
Run Code Online (Sandbox Code Playgroud)

以下是我使用后安装的软件包的详细信息polars.show_versions() …

parquet python-polars

8
推荐指数
0
解决办法
2648
查看次数

Rxjs Observable按顺序运行并返回一个数组

var arr = [obs1, obs2, obs3];
Observable.forkJoin(...arr).subscribe(function (observableItems) {})
Run Code Online (Sandbox Code Playgroud)

并行运行observable并返回一个数组.

如何顺序运行observable 返回一个数组.我不想为每个观察者打电话,所以concat()不适合我.

我想收到相同的最终结果,forkJoin但顺序运行.

它存在吗?或者我必须编写自己的可观察模式?

observable rxjs

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

在不使用jQuery将图片上传到服务器之前,如何从输入标签获取Angular 2(或更高版本)中图片的高度和宽度?

我检查了各种来源,但大多数解决方案都在jQuery中。如果可能的话,我希望在Typescript中提供解决方案。

HTML-

<input #coverFilesInput class="file-input" type="file"(change)="onChange($event)"....>

打字稿-

onChange($event) { let img = event.target.files[0]; // and then I need code to validate image size }
Run Code Online (Sandbox Code Playgroud)

有解决方案还是我做错了?

file-upload typescript angular

5
推荐指数
3
解决办法
9617
查看次数

如何使用与 T 不同类型的 Proxy&lt;T&gt; 作为参数?

我处于一种情况,我想使用Proxy, 在类列表之间“负载平衡”。

我想做的一个简单的例子如下:

class Foo {
    constructor(private msg: string) {}

    foo() {
        console.log(this.msg);
    }
}

// @ts-ignore
const proxy: Foo = new Proxy([new Foo('foo'), new Foo('bar')], {
    get: (o, key) => {
        const client = o[Math.floor(Math.random() * o.length)];
        console.log(client, key);
        return client[key];
    },
});
proxy.foo();
Run Code Online (Sandbox Code Playgroud)

这“有效”。问题是我正在使用打字稿。而且,由于Proxy类型定义,我们不能做类似的事情

new Proxy<Foo>([new Foo(), new Foo()], handler)
Run Code Online (Sandbox Code Playgroud)

因为它会产生以下错误:

“Foo[]”类型的参数不可分配给“Foo”类型的参数。

有没有办法实现这一点;不丢失类型检查?

javascript typescript ecmascript-6

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

如何在Angular 6中使用http delete()

myService.ts

  import { Injectable } from '@angular/core';
  import { Http, Response,Headers,RequestOptions } from '@angular/http';
  import { Observable } from 'rxjs';
  import 'rxjs/Rx';
  import{Router} from'@angular/router';
  import 'rxjs/add/operator/map';
  @Injectable()
  export class ManageJobDeleteService{
    constructor(private http: Http,private router:Router){};
    DeleteRequestToAPI(post_jobs_id:string){
       let body = JSON.stringify({post_jobs_id:post_jobs_id});
       let headers = new Headers({ 'Content-Type': 'application/json'});
       let options = new RequestOptions({ headers: headers });
        console.log(body);
        console.log(options);
      return this.http.delete('http://127.0.0.1:8000/api/employer/post_jobs/',body,options)//HERE I AM GETTING ERROR
      .map(this.extractData)
      .catch(this.handleError);
    }
   private extractData(res: Response){
      let body = res.json();
      console.log(body);
      return body || [];   
    }
    private handleError …
Run Code Online (Sandbox Code Playgroud)

rest typescript angular angular6

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

如何清除提供者缓存以与 Angular 7 中的 useFactory 一起使用

我正在动态创建元素,其中一个元素使用@Inject解析为工厂的令牌。

问题在于工厂实例缓存在节点索引上。一旦我的元素从视图中消失并返回,我希望能够调用我的工厂函数;但我不。相反,我得到了这个工厂实例的缓存版本。

在此输入图像描述

如何确保对象从视图中消失后不使用缓存?

基本上,当我的@Component构造函数被调用时,我期望一个全新的服务。不是缓存服务。

@Inject(FORM_GROUP_MANAGER_SERVICE)
private formGroupManagerService: FormGroupManagerServiceImpl
Run Code Online (Sandbox Code Playgroud)
{
    provide: FORM_GROUP_MANAGER_SERVICE,
    useFactory: (structureControlService, createTonicControlFactory, parent) => new FormGroupManagerService(
        structureControlService,
        createTonicControlFactory,
        parent
    ),
    deps: [StructureControlService, FORM_GROUP_MANAGER_SERVICE_CREATE_CONTROL, [new Optional(), FormGroupManagerService]]
},
Run Code Online (Sandbox Code Playgroud)

dependency-injection angular angular7

5
推荐指数
1
解决办法
1016
查看次数

adfs 和 azure AD 之间的区别

ADFS 和 Azure AD 之间的差异

  1. 据我了解,ADFS 是一种 STS(安全令牌服务),因为它向应用程序颁发令牌,帮助应用程序建立用户身份。在组织级别,我们的组织使用 ADFS 和 WS-Federation 协议来对组织所有内部应用程序中的用户进行身份验证,并实施 SSO。

  2. 此外,在我们的组织中,我们有 Azure AD 帐户,并且我使用 Azure AD 来注册我们的自定义应用程序,每当未经身份验证的用户进入我们的应用程序时,该人将重定向到 azure ad 登录页面,并且必须对自己进行身份验证。身份验证成功后,Azure AD 还会颁发令牌(ID 令牌、访问令牌、刷新令牌)

我的问题是,我是否可以将 Azure AD 视为一种 STS(安全令牌服务),就像 ADFS 一样,因为它会颁发令牌来建立客户端身份?

adfs azure ws-federation azure-active-directory

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

如何在php中创建目录?

我当前的文件夹路径是$path = car_images; 它对我有用。我可以直接将我的图片上传到这个文件夹中。但我想为每个用户创建单独的文件夹。所以现在图像应该上传到$path = car_images/$emp_code;

意味着我想首先$emp_codecar_images文件夹中创建名称为目录的目录,然后将$emp_code图像上传到目录中。

我当前的代码没有在 car_images 文件夹中创建目录。

           $path = "car_images/".$emp_code;
           if (!is_dir($path.'/'.$emp_code)) 
           {
             mkdir($path.'/'.$emp_code, 0777, true);
           } 
           $name = $_FILES['car_images']['name'][$i];
           $size = $_FILES['car_images']['size'][$i];
           list($txt, $ext) = explode(".", $name);
           $file= time().substr(str_replace(" ", "_", $txt), 0);
           $info = pathinfo($file);
           $filename = $file.".".$ext;
           if(move_uploaded_file($_FILES['car_images']['tmp_name'][$i], $path.$filename)) 
            { 
               $file_name_all.=$filename.",";
            }
Run Code Online (Sandbox Code Playgroud)

php upload

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

类型脚本-角度:静态喷油器错误

嗨,我正在尝试在我的有角项目中使用socket.io。我要显示的三个文件是组件文件,一个服务文件和一个模块文件。每当我在组件文件中使用服务时,都会得到静态注射器错误。这是:

错误:StaticInjectorError(AppModule)[AppComponent-> WrappedSocket]:StaticInjectorError(平台:核心)[AppComponent-> WrappedSocket]:
NullInjectorError:WrappedSocket没有提供者!

这是组件文件:

import { Component } from '@angular/core';   
import {  cheema2 } from './practice.service';
import { Injectable } from '@angular/core';
import { Socket } from 'ng-socket-io';

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

 @Injectable()    
 export class AppComponent  
 {   
     constructor(private socket: Socket) { }

     sendMessage(msg: string){
     this.socket.emit("message", msg);
   }

   getMessage() 
   {
     console.log( this.socket.fromEvent("message"));
   }

}
Run Code Online (Sandbox Code Playgroud)

这是模块文件

import { BrowserModule } from '@angular/platform-browser';   
import { NgModule } from '@angular/core';
import { SocketIoModule, SocketIoConfig } from 'ng-socket-io'; …
Run Code Online (Sandbox Code Playgroud)

sockets dependency-injection typescript angular

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

类型对象上不存在属性长度

我有一个从docker获取JSON的服务。我想获取容器的数量。

因此,我订阅了我的服务:

ngOnInit() {
    this.docker.getContainers().subscribe(containers => {
        console.log(containers.length);
    });
}
Run Code Online (Sandbox Code Playgroud)

我在控制台上得到了正确的答案,但是我得到了:

类型对象上不存在属性长度

难道我做错了什么?

export class DockerService {
  private baseUrl:string = 'http://localhost:8080/api/docker';
  private headers = new HttpHeaders({'Content-Type':'application/json'});
  private options = new HttpHeaderResponse({headers:this.headers});

  constructor(private _http:HttpClient) { }

  getContainers() {
    return this._http.get(this.baseUrl + "/containers", this.options);
  }

  getImages() {
    return this._http.get(this.baseUrl + "/images", this.options);
  }
}
Run Code Online (Sandbox Code Playgroud)

typescript angular

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

多个httpclient post调用进入foreach循环angular 5

我需要使用httpclient进入foreach循环。有可能的?正确的方法是什么?这是我的代码:

this.attachToDelete.forEach( 
          element => {
            this.documentService.DeleteAttachment(element, this.newDocumentId.toString());
            console.log("upload delete from submit", element);
          }
        );
Run Code Online (Sandbox Code Playgroud)

这是对应服务中的方法:

public DeleteAttachment(attachmentId: number, documentId: string) {    
    let headers = new HttpHeaders();
    headers = headers.set('Content-Type', 'application/json; charset=utf-8');
    return this.http.post('http://localhost:8080/DocumentAPI/api/document/RemoveAttachment?docId=' + documentId + '&attachmentId='+attachmentId, attachmentId,  { headers: headers }).subscribe(
      data => { 
        if(data)
        console.log("delete attach????", data);
        else{
          console.log('Error occured');
        } 
      }     
    );
  }
Run Code Online (Sandbox Code Playgroud)

post call httpclient rxjs angular

0
推荐指数
1
解决办法
2817
查看次数