小编veb*_*ben的帖子

Angular 7 - 出现错误:'rxjs 没有导出成员'Observable'

这是我的package.json文件:

"dependencies": {
    "@angular/animations": "~7.1.0",
    "@angular/common": "~7.1.0",
    "@angular/compiler": "~7.1.0",
    "@angular/core": "~7.1.0",
    "@angular/forms": "~7.1.0",
    "@angular/material": "^7.1.1",
    "@angular/platform-browser": "~7.1.0",
    "@angular/platform-browser-dynamic": "~7.1.0",
    "@angular/router": "~7.1.0",
    "core-js": "^2.5.4",
    "ng2-opd-popup": "^1.1.21",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.8.26"
Run Code Online (Sandbox Code Playgroud)

service.ts文件代码如下:

import { Injectable } from '@angular/core';
import { Http, Headers} from '@angular/http';
import 'rxjs/add/operator/map';
//import { Observable } from 'rxjs/Observable';
//import   'rxjs/add/observable';
import { Observable} from 'rxjs';
@Injectable({
  providedIn: 'root'
})
export class EmpService {
  employees=[];
  constructor(private _http: Http) { }
  addEmployee(info){
    return this._http.post("http://localhost/data/insert.php",info)
      .map(()=>""); …
Run Code Online (Sandbox Code Playgroud)

rxjs typescript angular rxjs6 angular7

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

Angular-在Http.post中接收并返回Observable <T>响应

我实现了一个返回Observable的方法。在此方法内部,我使用http.post向后端发送请求。接收到响应(它是一个JSON对象)后,我要将其存储在Observable变量中并返回该变量。但是我不知怎么解决了那个问题。在.subscribe中,res变量没有存储在postResponse变量中,但是我可以在“本地” console.log中看到res变量具有正确的值。全局console.log为空。此外,我得到了错误:

错误“ TS2322:类型'ArqResponse'无法分配为类型'可观察'”返回错误。

我的代码如下所示:

postARQRequest(request): Observable<ArqResponse>{
    let postResponse = new ArqResponse;
    const result = this.http.post<ArqResponse>(this.arqUrl, request)
                       .subscribe((res: ArqResponse) => { postResponse = res; console.log('shadow: ' + res)});
    console.log('global: ' + JSON.stringify(postResponse));
    return postResponse;
}
Run Code Online (Sandbox Code Playgroud)

我的问题是:

  1. 如何将响应主体存储在变量中,然后可以将其返回?
  2. 如何将ArqResponse变量“投射”到Observable变量?
  3. .subscribe 似乎是错误的,因为我得到:

this.arqService.postARQRequest(...)。subscribe不是函数错误

observable rxjs typescript angular rxjs6

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

`chmod` 不适用于 Dockerfile (macbook)

我目前正在开发一个Dockerfile,它要求我拥有对两个特定文件夹进行读取、写入和执行的权限。当需要运行命令时chmod,它就会失败。我可以在 docker 容器内手动更改权限,但它似乎没有从命令中获取它。这是目前的样子:

FROM <image-source>
SHELL ["/bin/bash", "-c"]
USER root
WORKDIR /bla/bla
COPY . .
CMD chmod 777 -R /src/main/*
CMD chmod 777 -R /app/main/*
Run Code Online (Sandbox Code Playgroud)

shell docker dockerfile devops

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

Docker在入口点运行脚本

在Dockerfile中我定义了一个入口点:

ENTRYPOINT ["sh", "./docker-entrypoint.sh"]
Run Code Online (Sandbox Code Playgroud)

docker-entrypoint.sh,我想从中创建一个文件(file.json)template.json,这只是用实际值替换一些环境变量.

#! /bin/bash

eval "echo \"$(<template.json)\"" > file.json; npm start
Run Code Online (Sandbox Code Playgroud)

进入容器后,我看到file.json是空的.但是如果我在容器内的bash提示符中执行完全相同的命令,它就可以工作,并且我会看到所需的内容file.json.

为什么会这样?

bash docker dockerfile

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

如何将angular7降级到angular6

我尝试通过运行以下命令将7号角降级为6npm号角:

npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@6.1.1
Run Code Online (Sandbox Code Playgroud)

但是,我的文件中仍显示angular/cli 7版本package.json。我需要帮助以降级angular7angular6

npm typescript angular-cli angular6 angular7

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

带有 blobfuse 或 Azure 存储 Blob 的 Azure 容器实例

我正在从 azure 容器注册表(azure cli 和/或门户)部署到 azure 容器实例。Azure blobfuse(在 ubuntu 18 上)给了我以下错误:

未找到设备,请先尝试“modprobe 保险丝”。

解决方案是--cap-add=SYS_ADMIN --device /dev/fuse在启动容器(docker run)时使用标志:

安装 davfs2 卷时无法打开 docker 容器中的保险丝设备

但是,--cap-addACI 不支持该标志:

https://social.msdn.microsoft.com/Forums/azure/en-US/20b5c3f8-f849-4da2-92d9-374a37e6f446/addremove-linux-capabilities-for-docker-container?forum=WAVirtualMachinesforWindows

AzureFiles 对于我们的场景来说太昂贵了。

关于如何从 ACI 中的 Docker Linux 容器使用 blobfuse 或 Azure Blob 存储(准本地来自 nodejs)的任何建议?

azure azure-storage docker azure-container-registry azure-container-instances

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

Angular2-如何在* ngIf中使用字符串枚举

在Angular中enum使用时如何传递给函数*ngIf

我有以下代码:

export enum RoleType {
    User='User',
    Admin='Admin'
}
Run Code Online (Sandbox Code Playgroud)

组件功能

public hasAccess(role: RoleType) {
   //check role type and return true or false
}
Run Code Online (Sandbox Code Playgroud)

组件html

<div id="adminDiv" *ngIf="hasAccess('Admin')">
</div>
Run Code Online (Sandbox Code Playgroud)

当我构建它时,它一直在抱怨。它不能将字符串转换为枚举,是否有办法解决?

enums typescript angular angular7

2
推荐指数
3
解决办法
1949
查看次数

Netbeans 10.0 无法在 Windows 10 操作系统中启动

我刚刚下载Netbeans 10.0,在 Windows 10 64 位上执行时它无法启动netbeans64.exe(即使使用netbeans.exe

我删除了所有java安装并安装了jdk-11.0.2+9jdk-11.0.2+9-jre.

还将netbeans配置文件中的路径更改为正确的java路径。

配置环境变量PATHJAVA_HOME

运行应用程序时没有任何反应。

还有其他人有同样的问题吗?

java netbeans

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

从docker容器访问windows机器的文件

我在Windows 10操作系统中安装了Docker Desktop for Windows.我在docker容器中运行一个python脚本,它从磁盘读取文件并在文件末尾添加一些文本.现在要求是从Windows 10读取文件并对其执行相同的操作.

是否可以在docker中从Dock上运行的文件中读取文件?

docker docker-machine docker-volume docker-for-windows docker-desktop

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

Angular 6,滚动到顶部

我在 angular 6 应用程序中遇到了一个问题。附加路线时,滚动条不会改变其位置。我希望它在附加路线时滚动到页面顶部。 http://localhost:4200/#/pending-transfer是初始路线。用户单击页面中的按钮后,路由将附加到http://localhost:4200/#/pending-transfer/2595/62. 我试过使用window.scrollTo(0,0)in ngOnInit(),但这没有用。

javascript scrollto typescript angular angular6

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