angular 自定义指令 link or controller
- Before compilation? – Controller
- After compilation? – Link
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'First ';
});
app.directive('exampleDirective', function() {
return {
restrict: 'E',
template: '<p>Hello {{name}}!</p>',
controller: function($scope, $element){
$scope.name = $scope.name + "Second ";
},
link: function(scope, el, attr) {
scope.name = scope.name + "Third ";
}
}
})
结果:Hello First Second Third !
- “Am I just doing template and scope things?” – goes into controller
- “Am I adding some coolbeans jquery library?” – goes in link
angular 自定义指令 link or controller的更多相关文章
- angular 自定义指令 link
function link(scope, element, attrs) { ... } where: scope is an Angular scope object. element is the ...
- Angular自定义指令(directive)
angular自定义指令,意我们可以通过angula自己定义指令,来实现我们的特殊要求,为所欲为,一支穿云箭,千军万马来相见 多少年的老规矩了,先看代码: <!DOCTYPE html> ...
- angular 自定义指令详解 Directive
在angular中,Directive,自定义指令的学习,可以更好的理解angular指令的原理,当angular的指令不能满足你的需求的时候,嘿嘿,你就可以来看看这篇文章,自定义自己的指令,可以满足 ...
- angular自定义指令命名的那个坑
Directive 先从定义一个简单的指令开始. 定义一个指令本质上是在HTML中通过元素.属性.类或注释来添加功能.AngularJS的内置指令都是以ng开头,如果想自定义指令,建议自定义一个前缀代 ...
- Angular自定义指令directive:scope属性
在AngularJS中,除了内置指令如ng-click等,我们还可以自定义指令.自定义指令,是为了扩展DOM元素的功能.代码中,通过指定directive中的restrict属性,来决定这个指令是作为 ...
- angular自定义指令
1.在directive文件下创建指令的js文件 通常自定义指令需要声明模块(注意定义指令时, js内部指令名称需采用 aaAaBb驼峰的命名方式 html中使用的是aa-aa-bb) e.g (f ...
- angular自定义指令 repeat 循环结束事件;limitTo限制循环长度、限定开始位置
1.获取repeat循环结束: 自定义指令: .directive('repeatFinish', function () { return { link: function (scope, elem ...
- angular -- 自定义指令和模板
angular 可以自定义一些指令,来简化我们前端的工作量. 第一种:简单指令示例: <h3>自定义指令</h3> <sheng></sheng> &l ...
- angular 自定义指令 directive transclude 理解
项目中断断续续的用了下angular,也没狠下心 认真的学习.angular 特别是自定义指令这块 空白. transclude 定义是否将当前元素的内容转移到模板中.看解释有点抽象. 看解释有点抽象 ...
随机推荐
- mongodb 常用命令
转自http://www.blogjava.net/waterjava/archive/2011/03/23/346819.html 命令行 --help 显示命令行参数 --nodb 不连接数据库方 ...
- Java Socket Option
选项 public final static int TCP_NODELAY = 0x0001; public final static int SO_REUSEADDR = 0x04; public ...
- C语言解析json类型数据
转自:http://buluzhai.iteye.com/blog/845404 首先感谢作者!! 我使用的是cJSON:http://sourceforge.net/projects/cjson ...
- Ubuntu+Redis主从配置
软件环境: OS:ubuntu-12.04-desktop-amd64 Redis:redis-2.8.13.tar.gz TCL:tcl8.6.2-src.tar.gz VMware:vmware ...
- 各个JSON技术的比较
JSON技术的调研报告 一 .各个JSON技术的简介和优劣1.json-libjson-lib最开始的也是应用最广泛的json解析工具,json-lib 不好的地方确实是依赖于很多第三方包,包括com ...
- Objdump-查看汇编指令
作用 Objdump可以用来看汇编指令 查看汇编指令 测试文件 编译指令 gcc -g -o objtest 1.8.c objdump -S objtest |more /main 查看结果
- In App Purchase Statuses
In App Purchase StatusesThe following are the available states that can be assigned to your in app p ...
- php 配置本地自定义域名
一.设置host文件 二.设置httpd.conf # Virtual hosts Include conf/extra/httpd-vhosts.conf 三.设置httpd-vhosts.conf ...
- RouterOS软路由设置固定IP+PPPOE
内网: IP:192.168.10.254/24 网关:192.168.10.254 外网: IP:218.17.172.17/28 子网掩码:255.255.255.240 网关:218.17.17 ...
- SQL Server字符串函数(超实用)
1. len():计算字符串长度 2. lower().upper():字符串转换为大.小写 3. ltrim().rtrim():截去字符串左.右侧空格 4. space():返回由重复的空格组成的 ...