vue-typedi
Use typedi injections in Vue components
Usage
- Install module:
npm install vue-typedi --save
- Install reflect-metadata package:
npm install reflect-metadata --save
and import it somewhere in the global place of your app before any service declaration or import (for example in app.ts):
import "reflect-metadata";
- Enabled following settings in tsconfig.json:
"emitDecoratorMetadata": true,"experimentalDecorators": true,
- Use the module:
Vue.useVueTypedi;
Example
;;
Decorators
-
@Inject()
to inject a service in your Vue components or other services. -
@Injectable()
allows us to inject the services in non service classes.
License
This project is licensed under the MIT License - see the LICENSE.md file for details