从另一个控制器中删除数据 [英] dipsplay data from a controller in another
本文介绍了从另一个控制器中删除数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个控制器活动和学生,
i希望在活动中显示学生姓名作为下拉列表?
学生包含姓名和年龄
活动应包含学生姓名和日期的下拉列表。
i have 2 controllers event and students,
i would like to display student name in events as a dropdownlist ?
student contain name and age
event should contain a dropdownlist of student name and date .
推荐答案
如果你的意思是MVC,你不能(或者更确切地说,不应该)。无论一个还是另一个,数据都不会在控制器中显示。数据显示在视图中完成。所以,问题应该以某种方式重新制定,但是...视图不是由控制器直接操作的,正如您在协作图上看到的描述MVC模式: http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller 一> [ ^ ]。
因此,关于你可能的担忧,关键是视图和控制器之间的隔离,原则上,它允许你添加另一个controller ,无需重新定义视图。它只是为了正确地感知模式而减少了你的问题。您可以将此视为视图和控制器之间松散耦合的情况;另请参阅:
http://en.wikipedia.org/wiki/Loose_coupling [< a href =http://en.wikipedia.org/wiki/Loose_couplingtarget =_ blanktitle =New Window> ^ ]。
-SA
If you mean MVC, you cannot (or, rather, should not). Data is not "displayed" in a controller at all, no matter "one" or "another". Data presentation is done in a view. So, the problem should be reformulated somehow, but… the view is not manipulated directly by a controller, as you can see on the collaboration diagram describing MVC patter: http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller[^].
So, as to your possible concerns, the key is the isolation between a view and a controller, which, in principle, would allow you to add yet another controller without redefining the view(s). It reduced your problem just to the perceiving of the pattern correctly. You can consider this as a case of loose coupling between views and controllers; see also:
http://en.wikipedia.org/wiki/Loose_coupling[^].
—SA
这篇关于从另一个控制器中删除数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文