1

I have my data binding which is coming in from a web API and I am binding that to my view, however one field is causing a problem because it has a dot in the middle of the name desc_ci.serial_number, I am trying the following code so far:

API data structure from API

desc_ci.serial_number: "cxxxxxxxx"
description: ""
etc etc

html

<span class="text-gray">{{receivedIncident.desc_ci.serial_number}}</span>

.ts file

receivedIncident: any;


  constructor(private service: nowService,
    private appComponent: AppComponent,
    private userService: UserService,
    private router: Router,
    private http: HttpClient,
    private route: ActivatedRoute
  ) {
    this.receivedIncident = { number: '', opened_at: '', description: '', short_description: '', desc_ci.serial_number: ''}; this.receivedLocation = {city:null, country: null}
  }

private getIncident() {
    this.service.getIncident(this.s_id, this.c_id).subscribe((data) => {
      this.loading = true;
      console.log('Result - ', data);
      console.log('incident data is received');
      this.loading = true;
      this.receivedIncident = data.result[0];

    })
  }

I am getting errors: Cannot find the name 'desc_ci'??

Any ideas?

3
  • That is malformed json. The name should be quoted if there are illegal property name character. Example: "desc_ci.serial_number" : "value". Your code also needs to reference it correctly which you can do using a property indexer {{receivedIncident['desc_ci.serial_number']}} Commented Apr 10, 2019 at 11:00
  • how about binding that to the view? Commented Apr 10, 2019 at 11:03
  • That worked fine, could submit answer and I can accept. Commented Apr 10, 2019 at 11:05

1 Answer 1

1

Two possible problems.

  1. That is malformed json. The name should be quoted if there are illegal property name character. Example: "desc_ci.serial_number" : "value".

  2. Your code also needs to reference it correctly which you can do using a property indexer {{receivedIncident['desc_ci.serial_number']}}.

Sign up to request clarification or add additional context in comments.

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.