小编day*_*aes的帖子

AngularJS:手动$ compile vs自然$ compile通过递归指令

我试图用AngularJS创建我自己的递归指令,它调用自己用一个漂亮的JSON格式转换视图中的对象.好吧,首先我使用了一个ng-include调用一个带有模板的脚本,在其中使用ng-if验证当前值是否是一个对象,如果是,模板调用本身.

我一直认为这是一种不可思议的方法,所以我在一个指令中转换,更加简单.

越来越少......因为我发现了递归指令的世界,发现了很多东西,而且最有趣.我甚至在github上给它读了Angular的源代码(我建议你阅读:https://github.com/angular/angular.js),这是一件好事.

我搜索得如此努力,我想我几乎找到了能够珍惜我心灵的美妙!因为我学到了很多新东西而且你们都会帮助我.

在下面的链接中查看我的代码:https://github.com/Daymannovaes/htmljs/blob/master/js/directives/recursiveDataTemplateDirective.js

我的指令是:recursive-data-template ="data",其中data是一个对象.该指令将遍历此对象的键和值,如果值是对象,则将再次执行此操作.使用ng-if ="isObject(value)"进行条件.

好吧,我的第一个问题是无限循环.我需要在编译阶段删除内容,然后在postLink阶段强制编译内容.我的问题:**为什么手动编译不会出现无限循环的同一问题?**

我正在编译相同的内容,没有条件(如果if(!compiledContent)被删除,无限循环仍然没有发生),差异(我认为)只是他们在不同的地方,但我不是'能够在互联网上找到一个能解决我问题的人!

所以谢谢!(如果链接不起作用,这里是重要的代码):

compile: function(templateElement, templateAttributes) {
            /*
              in compile time, we need to remove the innerHTML of template(url) because of its recursive.
              Because of its recusiveness, when the $compile start to read the DOM tree and find a
              recursiveDataTemplate directive (even its not will be evaluated all time by link function
              because the ng-if, whatever) its start the do all the process again. So, …
Run Code Online (Sandbox Code Playgroud)

recursion compilation directive angularjs

6
推荐指数
1
解决办法
1617
查看次数

使用Node.js在Windows中叠加图标

为什么有任何节点包处理文件夹图标和覆盖图标,无论是Windows还是其他SO?

我做了一些研究,显然你需要写一个dll并注册它.https://msdn.microsoft.com/en-us/library/cc144123(v=vs.85).aspx

但这对Node不可能吗?因为我想创建一个具有不同图标的文件夹,我找不到一些简单的方法来使用javascript.

javascript node.js

5
推荐指数
0
解决办法
442
查看次数