title: How to fix this error Cannot read property 'attribut_id' of undefined
body: <p>At me at loading of page there is such error:</p>
  
  <blockquote>
    <p>ERROR TypeError: Cannot read property 'attribut_id' of undefined</p>
    
    <p>at eval (values.component.ts:132) </p>
    
    <p>at Array.filter () at
    SafeSubscriber.eval [as _next] (values.component.ts:132)</p>
    
    <p>at
    SafeSubscriber.__tryOrUnsub (Subscriber.js:243) </p>
    
    <p>at SafeSubscriber.next
    (Subscriber.js:190)</p>
    
    <p>at Subscriber._next (Subscriber.js:131)
     at Subscriber.next (Subscriber.js:95)</p>
    
    <p>at MapSubscriber._next (map.js:85)
    at MapSubscriber.Subscriber.next (Subscriber.js:95)</p>
    
    <p>at RefCountSubscriber.Subscriber._next (Subscriber.js:131)</p>
  </blockquote>
  
  <p>But the error does not always appear, and from time to time. And when error are not present the data is displayed completely, and if the error appeared then the data will not be displayed. </p>
  
  <pre><code>  id: number;
    routeId: any;
    returnUrl: string;
    sprTypeEvents: Array&lt;SprTypeEvent&gt;;
    eventAttributes: Array&lt;EventAttribute&gt;;
  
    filteredEventAttributes =[];
    _sprTypeEvent: SprTypeEvent;
  
    public errorMsg;
  
    constructor(
      public authService: AuthService, 
      private servSprTypeEvent: SprTypeEventService,
      private servEventAttribute: EventAttributeService,
      private router: Router,
      private route: ActivatedRoute
    ) {
      this.sprTypeEvents = new Array&lt;SprTypeEvent&gt;();
    }
  
    @Input() sprTypeEvent: SprTypeEvent;
  
    @Input('typeEvent') set typeEvent (value: SprTypeEvent) {
      this._sprTypeEvent = value;
      if(this._sprTypeEvent) {
          this.loadEventAttributes();  
      }
  }
  
    ngOnInit() {
      this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/layout/events';
      this.routeId = this.route.params.subscribe(
        params =&gt; {
          this.id = +params['id'];
        }
      )
      let sprTypeEventRequest = this.route.params.flatMap(
        (params: Params) =&gt; this.servSprTypeEvent.getSprTypeEvent(+params['id'])
      );
  
      sprTypeEventRequest.subscribe(
        response =&gt; this.sprTypeEvent = response.json(),  
        error =&gt; this.errorMsg = error
      );
  
    }
  
    private loadEventAttributes() {
      this.servEventAttribute.getEventAttributes().subscribe(
        eventAttribute =&gt; {
          this.eventAttributes = eventAttribute;
          this.filteredEventAttributes = this.eventAttributes.filter(
            (eventAttribute) =&gt; eventAttribute.spr_typeevents_id == this._sprTypeEvent.typeevent_id
          );
        }
      );
    }
  }
  </code></pre>
  
  <p>How it can be fixed?</p>