vue-typedi
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

vue-typedi

Use typedi injections in Vue components

Usage

  1. Install module:

npm install vue-typedi --save

  1. 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";

  1. Enabled following settings in tsconfig.json:
"emitDecoratorMetadata"true,
"experimentalDecorators"true,
  1. Use the module:
import Vue from 'vue'
import VueTypedi from 'vue-typedi'
 
Vue.use(VueTypedi);

Example

 
import { Inject } from 'vue-typedi';
import MyService from '...';
 
@Component
export default class MyComponent extends Vue {
 
  @Inject()
  public myService!: MyService;
}
 

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

Dependencies (2)

Dev Dependencies (17)

Package Sidebar

Install

npm i vue-typedi

Weekly Downloads

116

Version

1.1.1

License

MIT

Unpacked Size

11.8 kB

Total Files

15

Last publish

Collaborators

  • sascha245