Typescript looping through class type properties

前端 未结 2 1217
隐瞒了意图╮
隐瞒了意图╮ 2021-01-01 11:16

How can one loop through the properties of a class in TypeScript? Take the following class for example:

export class T         


        
2条回答
  •  佛祖请我去吃肉
    2021-01-01 12:05

    See How do I loop through or enumerate a JavaScript object?

    In your case, something like:

    for (var i in TodoApp.Task) {
        if (TodoApp.Task.hasOwnProperty(i)) {
            var th = $('').append(TodoApp.Task[i]);
            tHead.append(th);
        }
    }
    

提交回复
热议问题