angular $compiler
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的更多相关文章
- Java compiler level does not match解决方法
从别的地方导入一个项目的时候,经常会遇到eclipse/Myeclipse报Description Resource Path Location Type Java compiler level d ...
- idea报错:error java compilation failed internal java compiler error
idea下面报如下问题 error java compilation failed internal java compiler error 解决办法:Setting->Compiler-> ...
- 使用Google Closure Compiler高级压缩Javascript代码注意的几个地方
介绍 GCC(Google Closure Compiler)是由谷歌发布的Js代码压缩编译工具.它可以做到分析Js的代码,移除不需要的代码(dead code),并且去重写它,最后再进行压缩. 三种 ...
- SSE指令集学习:Compiler Intrinsic
大多数的函数是在库中,Intrinsic Function却内嵌在编译器中(built in to the compiler). 1. Intrinsic Function Intrinsic Fun ...
- c++ builder 2010 错误 F1004 Internal compiler error at 0x9740d99 with base 0x9
今天遇到一个奇怪的问题,拷贝项目后,在修改,会出现F1004 Internal compiler error at 0x9740d99 with base 0x9 ,不管怎么改,删除改动,都没用,关闭 ...
- 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 ...
- 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 ...
- idea Error:java: Compilation failed: internal java compiler error
idea 遇到Error:java: Compilation failed: internal java compiler error 是提示说你当前使用的编译器jdk版本不对. 按住Ctrl+Alt ...
- 关于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交叉 ...
- 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 错误,一般是项目移植出现 ...
随机推荐
- 新鲜出炉的JSON,拿走不谢!
一.JSON简介 1.JSON全称是JavaScript Object Notation即JavaScript对象标记法. JSON是一种轻量级(Light-Weight).基于文本的(Text-Ba ...
- BotVS开发基础—2.1 账户、行情、K线、深度
代码 import json def main(): Log("账号信息:", exchange.GetAccount()); # Log("K 线数据:", ...
- 一个利用pojo类从前端页面request中获取参数的小框架~
写之前不知道Spring已经实现这样的功能,所以傻傻的写了这个东西! 实现原理挺有趣的在此记录一下.从去年十月参加java开发以来自己终于有了点小进步. 好开心. 解决问题(详解):前端form表单提 ...
- 迈向angularjs2系列(6):路由机制
目录1.angular-seed的路由2.路由机制的探索3.懒加载 一:angular-seed的路由 step1:安装种子项目 $ git clone --depth 1 https://gi ...
- ruby开发环境搭建
ruby开发可以在max os .Linux系统或windows下进行.推荐使用linux系统,这里以在linux系统下搭建开发环境为例.大体上需要以下几步: 一.下载并安装virtualbox和ub ...
- 【BUG】插入或者更新超过限制后写入数据库失败
Error Code: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your ...
- 即时通信系统Openfire分析之四:消息路由
两个人的孤独 两个人的孤独,大抵是,你每发出去一句话,都要经由无数网络.由几百个计算机处理后,出在他的面前,而他就在你不远处. 连接管理之后 Openfire使用MINA网络框架,并设置Connect ...
- Tornado-数据库(torndb包)
1.torndb数据库简介 在Tornado3.0版本以前提供tornado.database模块用来操作MySQL数据库,而从3.0版本开始,此模块就被独立出来,作为torndb包单独提供. ...
- kappa系数在评测中的应用
◆版权声明:本文出自胖喵~的博客,转载必须注明出处. 转载请注明出处:http://www.cnblogs.com/by-dream/p/7091315.html 前言 最近打算把翻译质量的人工评测好 ...
- 教你自己搭建linux邮箱服务器
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt290 现在网络中流行的电子邮件系统主要有Microsoft Exchange ...