Andrew Graham-Yooll Andrew Graham-Yooll - 1 year ago 89
AngularJS Question

What is <T> in dynamic forms?

Im following the Angular2 cookbook recipe for Dynamic Forms. It calls for

export class QuestionBase<T>{
value: T,

I cant seem to find out what the is doing in both spots. Any ideas?

Answer Source

Those are so called "Generics". You may just google for the term "generics", for example in combination with "typescript", in order to get a more detailed answer.

The quick version is: with generics you do not care which type T is - as long as it is the same type everywhere you use it. So an instance of


has to make sure that the property "value" is of type String

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download