Basit Basit - 11 months ago 59
Javascript Question

typescript + angular2 pass class from a string value

class SimpleComponent {


var string = 'SimpleComponent';

bootstrapComponents.push(string); // This should be 'SimpleComponent' class and not a string value.

How can I pass class object from a string value in typescript?

Answer Source

add the class name as a key

var classPointer={'SimpleComponent':SimpleComponent};