vue-typedi

Use typedi injections in Vue components
8,624 17
Install
npm install vue-typedi
Latest Version:1.1.1
Vue:2
License:MIT
Last Updated:Nov 23, 2018
Links: GitHub  ·  npm
Maintainer: sascha245

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

Related Packages

vue

The progressive JavaScript framework for building modern web UI.

588,019,132 54,801
vue
@vueuse/shared
372,738,348 22,398
@vueuse/core

Collection of essential Vue Composition Utilities

367,188,523 22,398
@vitejs/plugin-vue

The official plugin for Vue SFC support in Vite.

333,357,380 686
eslint-plugin-vue

Official ESLint plugin for Vue.js

266,364,830 4,591

Version History

Version Released Vue License
1.1.1 ^2.5.17 MIT
1.1.0 ^2.5.17 MIT
1.0.0 ^2.5.17 MIT