在 Angular 2 中获取动态表单以从远程源获取问题

Getting Dynamic Forms in Angular 2 to get Questions from remote source

好的,实际上我想要做的只是让 https://angular.io/docs/ts/latest/cookbook/dynamic-form.html 执行 question.service.ts 中第一个 TODO 所说的。

真的,我该如何实现:// Todo:从问题元数据的远程来源获取。

我在这方面已经有一段时间了,作为一个初学者,我不知道该怎么做。我已经尝试了我能想到的一切,但仍然一无所获。拜托,即使是最细微的想法,我也会非常高兴。

提前致谢。

您正在寻找的是在您的服务器端创建一个 REST API,它将为您提供数据,并使用 HttpModule

在 Angular 应用程序中使用它
   // questionUrl -> 'api/auestions'

   getQuestions(): Promise<any[]> {
     return this.http.get(this.questionUrl)
           .toPromise()
           .then(response => response.json().data)
   }

您可以阅读更多相关内容here

希望对您有所帮助!!