Comments (3)
Hi @leomayer,
Dependencies need to be injected out of the method body:
withMethods((store, dialog = inject(MatDialog)) => ({
displayDialog() {
dialog.open(/* ... */)
}
}))
or:
withMethods((store) => {
const dialog = inject(MatDialog);
return {
displayDialog() {
dialog.open(/* ... */)
},
};
})
For any further question, feel free to join our Discord Server.
from platform.
@markostanimirovic : The first solution works, the second not - I get
Uncaught Error: NG0203: inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`
Anyway - since I don't care about the difference and I have a running workaround: Thx a lot for your immediate response.
from platform.
The first snippet is just a shorter version of the second one. In other words, they're equivalent.
Make sure that you copied the code correctly - inject
needs to be called within the withMethods
factory body, but out of the displayDialog
method.
from platform.
Related Issues (20)
- untracked for all methods? HOT 4
- @ngrx/signals: ability to save entity class instance on updateEntity() HOT 1
- Expose more models to the public API: SignalStoreFeatureResult and InputSignalStore<Input>
- Using a custom generic function for defining props in createActionGroup results in weird TypeScript errors HOT 4
- Chaining custom signal store features with input declared as functions fails HOT 2
- @ngrx/effects/src/effect_creator.d.ts:12:43 - error TS2313: Type parameter 'OT' has a circular constraint. HOT 17
- Schematics 'feature' gives error "Property 'entity' does not match the schema. 'false' should be a 'boolean'." HOT 8
- `patchState` TypeScript v5.4 compilation error HOT 3
- updater-explicit-return-type No longer needed with NoInfer HOT 2
- Cannot generate feature inside module with schematics HOT 2
- RFC: Allow constructor injection of SignalStore
- RFC: SignalStore with WritableSignals and ReadOnlySignalStore HOT 8
- Signal Store with Angular SSR initiate store in every injected component HOT 2
- Type 'Unsubscribable' must have a '[Symbol.iterator]()' method that returns an iterator. HOT 2
- Return type of selectQueryParam is incorrect HOT 2
- SignalStore Methods code snipped has probably a flaw HOT 4
- eslint plugin should use correct version of 'concatLatestFrom' in autofix for rule 'prefer-concat-latest-from' HOT 5
- Provide properly typed selectors example for CustomSerializer
- No usage notes for `tapResponse`, `concatLatestFrom` operators. HOT 1
- Ngrx dependency injection issue with esbuild/build-angular:application HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from platform.