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

[help] access the current field #3907

Open
its-dibo opened this issue May 6, 2024 · 0 comments
Open

[help] access the current field #3907

its-dibo opened this issue May 6, 2024 · 0 comments
Labels

Comments

@its-dibo
Copy link

its-dibo commented May 6, 2024

fields = [{
 key: "example",
 type: "select",
 props:{
  options: data$.pipe(
   //<------- access "field" here
    tap(res=>{ field.required = res.lengh>0 })
 )
}
}]

other solutions
I tried other solutions, but all of them are not elegant

  • access the field after creating the object
fields = [{ ... }]
fields[0].props.options = data$.pipe(
 tap(res=>{ fields[0].required = res.length>0 })
)
  • use init hook: this makes the code got more complicated, all logic of all props are existing in one function
  • use expressions: I want to set the initial state only, not watch for each chnges
  • use initializer function; not supported by formly
fields=[
 ...
  options: (field, model) => data$.pipe( ... )
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant