Sharping Up with Angularjs 1.x -Direactive
来源:互联网 发布:淘宝虚拟充值货源 编辑:程序博客网 时间:2024/06/06 03:13
1、基本指令声明
eg: app.directive('productGallery', function(){ return { restrict: 'E', templateUrl: 'product-gallery.html', controller: function(){ this.current = 0; this.setCurrent = function(imageNumber){ this.current = imageNumber || 0; }; }, controllerAs: 'gallery' }; });
restrict - 声明指令的使用方法:
E: 作为标签使用 <poduct-allery></poduct-gallery>
A: 作为属性使用 <div poductGallery></div>
C: 同类名绑定 <div class="poductGallery"></div>
M: 作为注释使用,不推荐
templateUrl - 声明需要加载的html模板,可以是html文件路径,也可以是一个函数。(可以使用 ng-include 实现动态 templateUrl,但是否更适合使用 ng-route 实现还有待验证)
controller 中可声明形如
this.addStrength = function() { $scope.abilities.push("strength");};
的函数,暴露给其他 direactive 调用
0 0
- Sharping Up with Angularjs 1.x -Direactive
- AngularJS(1.X)
- angularjs请求头中x-requested-with XHR
- AngularJS 1.x学习<1>
- AngularJS 1.x学习<2>
- (1)AngularJS 1.X 之 认识AngularJS
- Back Up with RMAN
- Setting up your Windows computer to run JPetStore 3.x with MySQL and Tomcat
- Setting up Wireless 802.1x with Windows Server 2008 and NPS
- (4)AngularJS 1.X 之控制器
- (8)AngularJS 1.X 之过滤器
- AngularJS 1.x入门·简介
- AngularJS(1.X)的一个表达式
- 1. Steps to set up java web project with IDEA
- AngularJs integrate with Yii
- AngularJS with Cookies Example
- AngularJS with MVC4 CRUD
- Setting up Eclipse with Tomcat
- 硬币趣味题
- 第二周项目1--C/C++语言中函数参数传递的三种方式
- Leetcode3:Longest Substring Without Repeating Characters
- 模拟消息队列
- ElasticSearch知识点整理
- Sharping Up with Angularjs 1.x -Direactive
- Unity UI(九):UI布局之Layout Element、Content Size Fitter和Aspect Ratio Fitter
- 大数相加和大数相乘
- JAVA IO流
- redis cluster 添加 删除 重分配 节点
- extern ‘C’
- [Android]两分钟教你学会用户登录,超级简单的小demo
- oclint规则 Migration(迁移)
- Handler机制,AsyncTask与aidl