'import loopback repository of one controller to another controller
in test.controller.ts file
import {repository} from '@loopback/repository';
import {ProductRepository} from '../repositories';
export class TestController {
constructor(
@repository(ProductRepository)
public productRepository: ProductRepository,
) { }
static async createData(data:any){
await this.productRepository.updatedById(11, {'code': 'asd1232d'});
return true;
}
}
gives me an error in vs code Property 'productRepository' does not exist on type 'typeof TestController'.
Solution 1:[1]
Your createData() is static you can't call an instance injected via your constructor in a static method.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Matthieu Riegler |
