ngneat / query

🚀 Powerful asynchronous state management, server-state utilities and data fetching for Angular Applications
https://ngneat.github.io/query
540 stars 39 forks source link

Error: NG0203 at assertInInjectionContext #186

Closed timsar2 closed 1 day ago

timsar2 commented 1 week ago

Which @ngneat/query-* package(s) are the source of the bug?

query

Is this a regression?

Yes

Description

Calling signal value from mutate object inside the html part has error, But if we define the signal part inside the ts file there is no erro:

addTodo = inject(TodosService).addTodo()
// addTodoSignal = this.addTodoSignal.result   <<---- uncomment me so the error will be gone

@if (addTodo.result(); as result) {
      @if (result.isLoading) {
        <p>Mutation is loading</p>
      }
      @if (result.isSuccess) {
        <p>Mutation was successful</p>
      }
      @if (result.isError) {
        <p>Mutation encountered an Error</p>
      }
    }

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

Error: NG0203
    at assertInInjectionContext (core.mjs:3441:15)
    at toSignal (rxjs-interop.mjs:174:70)
    at get result (ngneat-query.mjs:366:44)

Please provide the environment you discovered this bug in

No response

Anything else?

No response

Do you want to create a pull request?

No

luii commented 1 week ago

Please provide a link to a stackblitz with your current setup

luii commented 5 days ago

@timsar2 We need more Information e.g. a repository/stackblitz (for reproduction) to appropriatly work on this issue.