Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Signal Input Schematics #236

Closed
rainerhahnekamp opened this issue Jan 22, 2024 · 1 comment
Closed

[bug] Signal Input Schematics #236

rainerhahnekamp opened this issue Jan 22, 2024 · 1 comment

Comments

@rainerhahnekamp
Copy link
Contributor

Congrats to the schematics. Really good!

Unfortunately, I have the following file content which fails to migrate to Signals Input:

@Component({
  selector: 'app-request-info',
  templateUrl: './request-info.component.html',
  standalone: true,
  imports: [
    ReactiveFormsModule,
    MatFormFieldModule,
    MatIconModule,
    MatInputModule,
    MatButtonModule,
    AsyncPipe,
    NgIf,
  ],
})
export class RequestInfoComponent implements OnInit {
  #formBuilder = inject(NonNullableFormBuilder);
  #lookuper = inject(AddressLookuper);

  formGroup = this.#formBuilder.group({
    address: [''],
  });
  title = 'Request More Information';
  @Input() address = '';
  submitter$ = new Subject<void>();
  lookupResult$: Observable<string> | undefined;

  ngOnInit(): void {
    if (this.address) {
      this.formGroup.setValue({ address: this.address });
    }

    this.lookupResult$ = this.submitter$.pipe(
      switchMap(() => {
        assertDefined(this.formGroup.value.address);
        return this.#lookuper.lookup(this.formGroup.value.address);
      }),
      map((found) => (found ? 'Brochure sent' : 'Address not found')),
    );
  }

  search(): void {
    this.submitter$.next();
  }
}

This is the command I run and its output

image
@nartc
Copy link
Collaborator

nartc commented Jan 22, 2024

Thanks for providing the content. I'll work on a fix

@nartc nartc closed this as completed in 26e94a7 Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants