角控制器结构为多部分观点控制器、观点、结构、部分

2023-09-13 03:57:11 作者:努力奔向目标

我需要创建一个使用AngularJS和Web API中的一个SPA此布局。工作流去如下:

当控制器的负载,两组数据的获取获取从API(表格上方和表格的左边 - 例如2调用的 API /数据1 和 API /数据2 )当用户点击在上表中的一行,详细信息被提取到右侧的框( API / DATA1 / 3434 /细节的)当从详细信息框某些条目用户点击,则相关的项被突出显示在表中的左边。

我开始创建与它的一切,也是公开的属性一切必要的东西控制器的看法,但现在它看起来像这样(伪)

  myPageController    table1Data:数组< IData1Model取代;    table2Data:数组< IData2Model取代;    userSelectedFromTable1:IData1Model;    userSelectedFromTable2:IData2Model; 

我觉得这是不是真的很好的做法。有没有办法对部分suborganize成某种局部的看法?子控制器?或者,这是一种常见的做法?什么平常看起来控制器,当他要服务于多种类型的数据/ API端点样?

修改

我要澄清,这只是一个特定的页面(部分)更大的应用程序。大部分地区都只是前端的某一种数据,例如一个控制器,一个模型,一是API调用等想想页面为某种仪表板在哪里显示多种数据,并互相交流。

解决方案   

是有办法的部分suborganize成某种局部的看法?子控制器?

这些部件应该真正的指令的。你将不得不在左视图是一个指令,并正在与控制器指令作为的胶的两个指令实例之间的右视图。

因此​​控制器的概述:

  myPageController    tablesData:IData1Model [];    userSelectedTable:IData1Model; 
嵌入式控制器在CORBA平台的应用实现

I need to create this layout in a SPA using AngularJS and a web api. The workflow goes as follows:

When the controller loads, two sets of data get fetched from the api (table above and table to the left - e.g. 2 calls to api/data1 and api/data2) As soon as the user clicks a row in the upper table, detail information gets fetched into the box on the right side (api/data1/3434/detail) When the user clicks on certain entries from the detail information box, the related entries are being highlighted in the table to the left.

I started creating a view with everything in it, also a controller that exposes properties for all necessary stuff, but now it looks like this (pseudo)

myPageController
    table1Data : Array<IData1Model>;
    table2Data : Array<IData2Model>;
    userSelectedFromTable1 : IData1Model;
    userSelectedFromTable2 : IData2Model;

I feel this isn't really good practice. Is there a way to suborganize the parts into some kind of partial views? Subcontrollers? Or is this a common approach? What does the usual controller looks like when he's going to serve for multiple kinds of data / api endpoints?

EDIT

I should clarify that this is just one particular page (section) of a bigger app. Most parts are just frontends for one kind of data, e.g. one controller, one model, one api call etc. Think of the page as some kind of dashboard where multiple data is shown and interact with each other.

解决方案

is there a way to suborganize the parts into some kind of partial views? Subcontrollers?

These parts should really be directives. You would have the left view being a directive and the right view being a directive with the controller being the glue between the two directive instances.

so an overview of the controller:

myPageController
    tablesData : IData1Model[];
    userSelectedTable : IData1Model;