简体   繁体   English

Angular 4应用程序收到ViewComponent ASP.Core服务器响应

[英]Angular 4 application receiving ViewComponent ASP.Core server responses

I am trying to build a single-page application with an ASP.Core + Angular 4 stack. 我正在尝试使用ASP.Core + Angular 4堆栈构建单页应用程序。 The server is supposed to provide view components, which will be rendered client-side and populated with additional data. 服务器应该提供视图组件,这些视图组件将在客户端呈现并填充其他数据。

The best way to create components would be utilising ViewComponent mechanic on the server, which allows me to effectively create HTML layouts and populate my HTML components with data from DB. 创建组件的最佳方法是利用服务器上的ViewComponent机械师,这使我可以有效地创建HTML布局,并使用来自数据库的数据填充HTML组件。 Alas, I have not yet found a way to transfer the data to my Angular 4 client app. las,我尚未找到将数据传输到Angular 4客户端应用程序的方法。 The ViewComponents are not static resources, meaning I (most likely) can't transfer it as JSON-data, and even if I could, I'd have to teach my client how to unwrap it back into html, which would increase the load on the client. ViewComponents不是静态资源,这意味着(最有可能)我无法将其作为JSON数据进行传输,即使可以,我也必须教我的客户端如何将其重新包装回html,这会增加负担在客户端上。

I have confirmed that JQuery calls can be made to receive IViewComponentResult responses, but I am yet to find a way on how to achieve same results in an Angular component. 我已经确认可以进行JQuery调用以接收IViewComponentResult响应,但是我还没有找到一种方法来在Angular组件中实现相同的结果。 Any help would be appreciated. 任何帮助,将不胜感激。

Usually with this stack you use .NET Core as the backend meaning you use it to write the Web API code which interacts with the database. 通常,在此堆栈中,您使用.NET Core作为后端,这意味着您可以使用它编写与数据库交互的Web API代码。 The Angular side of things would have services which call the Web API via http methods and present/manipulate the data in component.html/.css/.ts files. 事情的Angular方面将提供services ,这些services可通过http方法调用Web API ,并在component.html/.css/.ts文件中显示/操作数据。

You can read through a guide such as this to get an idea of the structure and flow of the stack. 您可以通过引导,如阅读获取堆栈的结构和流程的想法。 Everything you mentioned in your 2nd paragraph can be achieved through this architecture without the worry of transferring ViewComponents . 您在第二段中提到的所有内容都可以通过此体系结构实现,而不必担心传输ViewComponents

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM