Angularjs Angular中递归指令内容的双向绑定?
我想生成一个递归结构的文档,对应于我模型中的树结构 整个文档是可编辑的,模型应该对视图中的Angularjs Angular中递归指令内容的双向绑定?,angularjs,angularjs-directive,Angularjs,Angularjs Directive,我想生成一个递归结构的文档,对应于我模型中的树结构 整个文档是可编辑的,模型应该对视图中的所做的更改做出反应 我使用递归助手模块来避免无休止的循环。我仍在试图找出帖子链接、编译等 我有点搞不清楚哪些元素与哪些控制器和作用域相关联 我知道在每个递归级别都创建了一个iscolate范围,但我不确定这会如何影响我引用该iscolate范围内的变量作为绑定到的模型的能力 在mymain.js中: .directive('bullet',function(RecursionHelper){ ret
所做的更改做出反应
我使用递归助手模块来避免无休止的循环。我仍在试图找出帖子链接、编译等
我有点搞不清楚哪些元素与哪些控制器和作用域相关联
我知道在每个递归级别都创建了一个iscolate范围,但我不确定这会如何影响我引用该iscolate范围内的变量作为绑定到的模型的能力
在mymain.js
中:
.directive('bullet',function(RecursionHelper){
return {
restrict: "E",
scope:
{
node: '=node',
},
controller: function(),
template:
`
<button class="btn btn-default" ng-click="node.toggleExpanded()" ng-show="node.children.length != 0">
<span ng-show="!node.expanded" class="glyphicon glyphicon-plus" aria-hidden="true"></span>
<span ng-show="node.expanded" class="glyphicon glyphicon-minus" aria-hidden="true"></span>
</button>
{{node.content}}
<ul class="list-group-sm" ng-show="node.expanded">
<li class="list-group-item" ng-repeat="child in node.children">
<bullet node="child" ng-model="child"></bullet>
</li>
</ul>
`,
compile: function(element) {
return RecursionHelper.compile(element, function(scope, elm, attrs, ctrl, transcludeFn){
});
}
}
})
这是一个很难的话题。我很了解angular,但我仍然不完全理解。我所知道的是,如果你花几个小时理解这一页上的所有内容:你会更好地理解。谢谢你——这让我感觉好一点!我一直在读一本又一本关于$compile的书。我想我必须在链接方法中进行绑定,我只是不确定如何进行。你看到了吗。有许多有用的方法,还显示了link函数如何返回编译函数。我认为很多理解上的困难来自于返回函数的函数,返回函数等等。它可以得到一点“初始值”…你们有并没有可能为此提供一个插件?
<ul class="list-group-sm" contentEditable="true">
<li class="list-group-item" ng-repeat="child in currentBullet.children">
<bullet node="child"> </bullet>
</li>
</ul>