我想要实现的是在我的应用程序中有两个不同的模板:一个是通过ng-repeat生成的,如下所示:
<div ng-repeat="data in tree" ng-include="'templates/question.html'"></div>
另一个是这样生成的:
<div ng-include="'templates/question_editor.html'"></div>
所以基本上问题模板将由用户在按钮点击时生成,它也可以使用ng-repeat在另一个问题中嵌套一个问题。
我想要完成的是每当我点击其中一个问题div(我的问题模板基本上是一个div结构)时,我想要那个div里面的信息(如果有的话)(可能是几个字段)每个问题的唯一信息),将填充到我的question_editor模板中的某些字段中,当我更新question_editor模板字段时,它将实时更新被点击的问题中的字段。
我在想的是使用一个控制器并以某种方式将变量从问题传递给question_editor并填充question_editor的字段。为每个模板使用不同的控制器,然后在不同的控制器之间传递信息会更好吗?
jsFiddle只显示我的div的结构:http://jsfiddle.net/cwrEn/1/