directive是如何被compiled

HTML编译发生在三个阶段:

1.$compile遍历DOM节点匹配directives

如果compiler找到元素上的directive,directive就会被加入匹配DOM元素的directives list列表中,一个元素可以有多个directives

2.绑定在DOM元素上的所有directives一旦被确定,compiler会按优先级给directives排序

每个directive的compile函数都会被执行。每个compile函数都有一次改变DOM的机会。每个compile函数都返回link函数。这些函数调用每个directive返回的link函数构成组合链接函数

3.$compile通过调用上一步讲述的组合链接函数来链接scope和template。依次调用directives的link函数,给每个directive配置注册元素监听事件,设置scope的$watch监听器

var $compile = ...; // injected into your code
var scope = ...;
var parent = ...; // DOM element where the compiled template can be appended var html = '<div ng-bind="exp"></div>'; // Step 1: parse HTML into DOM element
var template = angular.element(html); // Step 2: compile the template
var linkFn = $compile(template); // Step 3: link the compiled template with the scope.
var element = linkFn(scope); // Step 4: Append to DOM (optional)
parent.appendChild(element);

angular $compiler的更多相关文章

  1. Java compiler level does not match解决方法

    从别的地方导入一个项目的时候,经常会遇到eclipse/Myeclipse报Description  Resource Path Location Type Java compiler level d ...

  2. idea报错:error java compilation failed internal java compiler error

    idea下面报如下问题 error java compilation failed internal java compiler error 解决办法:Setting->Compiler-> ...

  3. 使用Google Closure Compiler高级压缩Javascript代码注意的几个地方

    介绍 GCC(Google Closure Compiler)是由谷歌发布的Js代码压缩编译工具.它可以做到分析Js的代码,移除不需要的代码(dead code),并且去重写它,最后再进行压缩. 三种 ...

  4. SSE指令集学习:Compiler Intrinsic

    大多数的函数是在库中,Intrinsic Function却内嵌在编译器中(built in to the compiler). 1. Intrinsic Function Intrinsic Fun ...

  5. c++ builder 2010 错误 F1004 Internal compiler error at 0x9740d99 with base 0x9

    今天遇到一个奇怪的问题,拷贝项目后,在修改,会出现F1004 Internal compiler error at 0x9740d99 with base 0x9 ,不管怎么改,删除改动,都没用,关闭 ...

  6. Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead的解决办法

    今天在导入工程进Eclipse的时候竟然出错了,控制台输出的是: [2013-02-04 22:17:13 - takepicture] Android requires compiler compl ...

  7. Compiler Error Message: CS0016: Could not write to output file 回绝访问

    Compiler Error Message: CS0016: Could not write to output file 'c:\Windows...dll' 拒绝访问 C:\Windows\Te ...

  8. idea Error:java: Compilation failed: internal java compiler error

    idea 遇到Error:java: Compilation failed: internal java compiler error 是提示说你当前使用的编译器jdk版本不对. 按住Ctrl+Alt ...

  9. 关于The C compiler "arm-none-eabi-gcc" is not able to compile a simple test program. 的错误自省...

    在 GCC ARM Embedded https://launchpad.net/gcc-arm-embedded/ 上面下载了个arm-none-eabi-gcc 用cmake 编译时 #指定C交叉 ...

  10. java compiler level does not match the version of the installed java project facet 解决方案

    项目出现 java compiler level does not match the version of the installed java project facet 错误,一般是项目移植出现 ...

随机推荐

  1. 【前端】react学习阶段总结,学习react、react-router与redux的这些事儿

    前言 借用阮一峰的一句话:真正学会 React 是一个漫长的过程. 这句话在我接触react深入以后,更有感触了.整个react体系都是全新的,最初做简单的应用,仅仅使用react-tools打包js ...

  2. anaconda安装加速镜像问题解决

    Anaconda使用conda连接网络出现错误 我使用的是windows10 64bit下的Anaconda2,在安装和更新包的时候出现以下报错信息. 这是使用默认源安装包的报错信息: C:Users ...

  3. ie启动不了的解决办法,win7,win8都可以

    今天我的IE也无法打开了,我装的是win7的系统,ie升级到了IE11,无法打开了,看到下面这篇文章,借鉴试试,没想到也成功了. 按以上步骤,打开注册表, 第一步.按下Win+R组合键,在出现的运行命 ...

  4. KVM+Qemu+Libvirt实战

    上一篇的文章是为了给这一篇文件提供理论的基础,在这篇文章中我将带大家一起来实现在linux中虚拟出ubuntu的server版来 我们需要用KVM+Qemu+Libvirt来进行kvm全虚拟化,创建虚 ...

  5. java HashSet改用

    写的一个Student类如下: 上面是直接使用的HashSet集合,系统会把new Student()  当做地址不用来出来,所以结果如下: 然后我在Student类中重写了hashCode()和eq ...

  6. ASP.NET Core MVC I/O编程模型

    1. ASP.NET Core MVC I/O编程模型 1.1. I/O编程模型浅析 1.2. 同步阻塞I/O 1.3. 同步非阻塞I/O 1.4. 异步I/O 1.5. 总结 1.1. I/O编程模 ...

  7. Microsoft .Net Remoting系列专题之一:.Net Remoting基础篇

    Microsoft .Net Remoting系列专题之一 一.Remoting基础 什么是Remoting,简而言之,我们可以将其看作是一种分布式处理方式.从微软的产品角度来看,可以说Remotin ...

  8. jackjson和fastjson进行Bean与json互换

    1.jackjson 1.bean到json ObjectMapper m = new ObjectMapper(); String value = m.writeValueAsString(bean ...

  9. MySQL(十一)之触发器

    上一篇介绍的是比较简单的视图,其实用起来是相对比较简单的,以后有什么更多的关于视图的用法,到时候在自己补充.接下来让我们一起了解一下触发器的使用! 一.触发器概述 1.1.什么是触发器 触发器(Tri ...

  10. tomcat配置不用访问工程名

    <Host name="localhost" appBase="/server/webapps" unpackWARs="true" ...