# Angular: NG0950: Input is required but no value is available yet (input.required / viewChild.required)

**Code:** `NG0950` · **Category:** Angular · **Seen on:** Angular, TypeScript

A required signal input or query was read before Angular set it — in the constructor or too early in the lifecycle.

## Meaning

`input.required<T>()` (and `viewChild.required`, `contentChild.required`) throw NG0950 / NG0951 if read before a value exists. Read them in `ngOnInit` or later, inside `computed`/`effect`, or in the template. In tests, set the input with `fixture.componentRef.setInput(...)` before the first `detectChanges`.

## Common causes

- Reading `this.name()` in the constructor or a field initialiser that runs immediately
- Parent did not pass the required input (but the compiler is bypassed or the component is created dynamically)
- Test created the component without setting required inputs
- Reading a required view query before the view exists (NG0951)
- Dynamic component creation without `setInput`

## Quick fix

1. Read the input inside `computed()`, `effect()`, the template, or after init
2. In tests: `fixture.componentRef.setInput('name', 'Ada')` before `detectChanges()`
3. Use a non-required input with a default if the value can be missing

## Detailed fix by platform

### Angular

1. `fullName = computed(() => `${this.first()} ${this.last()}`);` instead of reading signals in the constructor
2. Dynamic: `ref.setInput('id', 7)`

## Code examples

### Read after init

```typescript
export class UserCardComponent {
  user = input.required<User>();
  title = computed(() => this.user().name);          // computed reads lazily: OK
  // constructor() { console.log(this.user()); }      // NG0950: nothing set yet
}
// test: fixture.componentRef.setInput('user', { name: 'Ada' }); fixture.detectChanges();
```

## How to diagnose

1. **Timing** — Where is the input read?
2. **Parent** — Is the required input bound?
3. **Test** — setInput before detectChanges?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/ng0950-required-input-no-value)
