1

Hi I want display my value from response http but I don't know what is the problem.

http :

getAllApiContext(){
     const options = this.getOptions("...");
    return this.http
        .get("jenkins/job/api_initialization/api/json", options)
        .map((data: any) => {
            return data.json().property[0].parameterDefinitions[1].choices;
        })
}

She return array.

My component.ts

context: Observable<Array<any>>;
ngOnInit() {
  this.jenkinsJob.getAllApiContext().subscribe(data => {
    this.context = data;
  });
};

My component.html

 <span *ngFor="let item of context | async">
   <p>{{item}}</p>
 </span>
1
  • What is the error or current behavior? Commented Jul 18, 2018 at 5:51

2 Answers 2

4

remove the async in the ngFor. since you are already subscribing to the observable, no need to use the async pipe

<span *ngFor="let item of context">
Sign up to request clarification or add additional context in comments.

Comments

3

If you want to use async pipe you don't need to subscribe

ngOnInit() {
 this.context = this.jenkinsJob.getAllApiContext();
};

AsyncPipe

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.