# @InjectProperty\<T>(key: string | Type\<T>)

Basically the same as [@Inject\<T>(key: string | Type\<T>)](/type-chef-di/fundamentals/decorators/inject-key-string.md) but with class properties.

```typescript
interface IFoo {
    getNumber(): number;
}

class Foo implements IFoo {
   getNumber() {
       return 69;
   }
}

class Foo2 implements IFoo {
    getNumber() {
        return 420;
    }
}
        
class Test {
        @InjectProperty('value')
        testProp: any;
        
        @InjectProperty('value2')
        testProp2: any;
        
        
        @InjectProperty<IFoo>(Foo)
        testProp!: IFoo; // 69

        @InjectProperty<IFoo>(Foo2)
        testProp2!: IFoo; //420
        
        constructor() {
        }
    }
    container.register('value', 'happy');
    container.register('value2', 'panda');
    container.register('test', Test);
    const testObj = await container.resolve<Test>('test');
    console.log(`I am a ${testObj.testProp} ${testObj.testProp2}`) // result: I am a happy panda
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://zer0-2.gitbook.io/type-chef-di/fundamentals/decorators/injectproperty-key-string.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
