Question: The component will render a list of values fetched from an API. I am getting the following component initialization issue:

```
Cannot set property 'hits' of undefined

```

display-recipes.component.ts:

```
import { Component, OnInit, Input} from '@angular/core';
import { SearchRecipeService } from '../search-recipe.service';
import { RecipeGlobal } from '../pojos/RecipeGlobal';

@Component({
  selector: 'app-display-recipes',
  templateUrl: './display-recipes.component.html',
  styleUrls: ['./display-recipes.component.css']
})
export class DisplayRecipesComponent implements OnInit {

  @Input() calories: String;
  @Input() recipe: String;
  recipeResult: RecipeGlobal;
  constructor(private searchRecipeService: SearchRecipeService) { }

  ngOnInit() {
     this.recipeResult.hits = [];
  }

  ngOnChanges(){
    this.getRecipeInfo();
  }

  getRecipeInfo(){
     this.searchRecipeService.getRecipeInfo().
     subscribe(recipeResult => this.recipeResult = recipeResult);
  }

}

```

display-recipes.component.html

```
<p>display-recipes works!</p>
<div id='display_recipe'  *ngFor="let recipe of recipeResult.hits">
    {{recipe.label}}
</div>

```

RecipeGlobal.ts

```
export class RecipeGlobal{
    q: String;
    hits: Recipe[];
}

export class Recipe{
    image: String;
    calories: String;
    label: String
}

```

I am failing to understand how objects are initialized in typescript. If I declare a non primitive inside the object, do I have to initialize it?. If so, in this case how should I initialize the array?.

Answer: 
You could write a quantification as follows :

```
sig Person {
  partner: Person
}

fact partnerProperties {
  all p1,p2:Person| p1.partner=p2 implies p2.partner=p1
  no p: Person | p in p.partner
}

run{}

```

Note that in that case persons can only have one partner each.
This model allows pluralism:

```
sig Person {
  partner: some Person
}

fact partnerProperties {
  all p1,p2:Person| p2 in p1.partner  implies p1 in p2.partner
  no p: Person | p in p.partner
}

run{} for 5

```
You make it a bit more concise by adding it as a fact to Person

```
sig Person { partner : Person } {
   this not in partner
   this in partner.@partner
}

```

A fact added to a `sig` will do an automatic quantification with `this` over all atoms of the `sig`. All fields that are part of the `sig` will be expanded with `this.` in front of them. This explains the use of the `@` sign. Without the `@` sign, the expansion would be:

```
sig Person { partner : Person } {
   this not in this.partner
   this in this.partner.this.partner
}

```

The `this.` is ok for the first `partner` but for the second `partner` the join must be with the result of `(this.partner)` and not `this`. The `@` sign before the second `partner` tells Alloy not to put `this` in front of the reference. The expansion then is:

```
sig Person { partner : Person } {
   this not in this.partner
   this in this.partner.partner
}

```

This is a solution:

```
┌───────────┬───────┐
│this/Person│partner│
├───────────┼───────┤
│Person⁰    │Person³│
├───────────┼───────┤
│Person¹    │Person²│
├───────────┼───────┤
│Person²    │Person¹│
├───────────┼───────┤
│Person³    │Person⁰│
└───────────┴───────┘

```