https://github.com/sascha245/vue-typedi
Use typedi injections in Vue components
https://github.com/sascha245/vue-typedi
typedi vue
Last synced: 11 days ago
JSON representation
Use typedi injections in Vue components
- Host: GitHub
- URL: https://github.com/sascha245/vue-typedi
- Owner: sascha245
- License: mit
- Created: 2018-11-22T22:27:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-23T10:38:36.000Z (over 6 years ago)
- Last Synced: 2025-03-18T16:12:19.136Z (2 months ago)
- Topics: typedi, vue
- Language: TypeScript
- Size: 13.7 KB
- Stars: 17
- Watchers: 0
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vue-typedi
Use [typedi](http://github.com/pleerock/typedi) injections in Vue components
## Usage
1. Install module:
`npm install vue-typedi --save`
2. 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";`
3. Enabled following settings in tsconfig.json:
```json
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
```4. Use the module:
```ts
import Vue from 'vue'
import VueTypedi from 'vue-typedi'Vue.use(VueTypedi);
```## Example
```ts
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](LICENSE.md) file for details