All Projects → sascha245 → vue-typedi

sascha245 / vue-typedi

Licence: MIT license
Use typedi injections in Vue components

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Labels

Projects that are alternatives of or similar to vue-typedi

resty
A Node.js framework
Stars: ✭ 20 (+11.11%)
Mutual labels:  typedi
Typedi
Simple yet powerful dependency injection tool for JavaScript and TypeScript.
Stars: ✭ 2,832 (+15633.33%)
Mutual labels:  typedi
Bulletproof Nodejs
Implementation of a bulletproof node.js API 🛡️
Stars: ✭ 4,369 (+24172.22%)
Mutual labels:  typedi
nodejs-boilerplate
Clean Architecture for node.js projects (Typescript + Express + TypeORM + Typedi)
Stars: ✭ 199 (+1005.56%)
Mutual labels:  typedi
express-typeorm-rest-boilerplate
Boilerplate code to get started with building RESTful API Services (Express, TypeORM MongoDB stack)
Stars: ✭ 53 (+194.44%)
Mutual labels:  typedi

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].