小编Cra*_*018的帖子

Angular 6 - ForkJoin没有导出成员

我已经更新到Angular 6并且我正在尝试使用ForkJoin,所以在我的服务上我有:

import { forkJoin } from 'rxjs/observable/forkJoin';
Run Code Online (Sandbox Code Playgroud)

但它没有认识到并且我得到了:

...ForkJoin has no exported member
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

rxjs typescript angular

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

带有凭证的Angular 6 httpClient Post

我有一些代码可以发布一些数据来创建数据记录。

它在服务中:

这是代码:

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

const httpOptions = {
  headers: new HttpHeaders({ 'Content-Type': 'application/json' })
};

@Injectable({
  providedIn: 'root'
})
export class ApiService {

  constructor(private http: HttpClient) { }

  create() {
      const postedData = { userid: 1, title: 'title here', body: 'body text' };
      return this.http.post('https://jsonplaceholder.typicode.com/posts', postedData, httpOptions).subscribe(result => {
        console.log(result);
      }, error => console.log('There was an error: '));
  }

}
Run Code Online (Sandbox Code Playgroud)

我的问题是...我该怎么做才能从用户登录时获得该网址的要求...我如何传递凭据?

javascript typescript angular angular6

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

Angular 6-隐藏或显示由服务触发的Div in组件

我有一项服务,该服务具有执行某些操作的方法。

service.ts:

doSomething() {
    // Does something here
}
Run Code Online (Sandbox Code Playgroud)

该服务与以下组件进行通讯:

myComponent.ts

我有:myComponent.html,其中有一个div:

<div class="myDiv">Something Here</div>
Run Code Online (Sandbox Code Playgroud)

我想要的是通过服务doSomething()方法中的代码显示和隐藏div。

像这样:

doSomething() {

    1. Show myDiv   
    2. // Do something here
    3. Hide myDiv
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

typescript angular angular6

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

Angular 6-httpClient发布XML文件

我正在使用Angular 6 httpClient并在服务中包含以下代码:

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

const httpOptions = {
  headers: new HttpHeaders({ 'Content-Type': 'text/xml' })
};

@Injectable({
  providedIn: 'root'
})
export class ApiService {

  constructor(private http: HttpClient) { }

  post() {
      const postedData = { userid: 1, title: 'title here', body: 'body text' };
      return this.http.post('this url here', postedData, httpOptions).subscribe(result => {
        console.log(result);
      }, error => console.log('There was an error: '));
  }

}
Run Code Online (Sandbox Code Playgroud)

我的问题是:我想发布一个xml文件,那么我该如何修改此代码呢?

typescript angular angular6

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

标签 统计

angular ×4

typescript ×4

angular6 ×3

javascript ×1

rxjs ×1