zoukankan      html  css  js  c++  java
  • Angularjs中编写指令模版

     1 angular.module('moduleName', []).directive(
     2         'namespaceDirectiveName',
     3         [ function() {
     4             return {
     5                 restrict : '',// 描述指令在模版中的使用方式,包括元素E,属性A,CSS样式类,注释或者以上方式的任意主和
     6                 priority : 0,// 设置指令在模版中的执行顺序,顺序是相对于其他指令而言
     7                 template : '',// 以字符串的形式编写一个内联模版,如果以url的形式提供模版,此属性会被忽略
     8                 templateUrl : '',// 描述加载模版所需要的url。如果使用temlate形式提供模版,此属性会被忽略
     9                 replace : true,// 如果设置为true则替换指令所在的元素,否则就追加到元素内部
    10                 transclude : true,// 把指令元素原来的子节点移动到一个新模版内部
    11                 scope : 'bool or object',// 为当前指令创建一个新的作用域,而不是使之继承父作用域
    12                 constroller : function($scope, $element, $attrs, $transclude) {
    13                     // 创建一个控制器,它会暴露一个API,利用这个API可以在多个指令之间进行通信
    14                 },
    15                 require : '',// 要求必须存在另个一指令,当前指令才能执行
    16                 link : function(scope, iElement, iAttrs) {
    17                     // 使用编程的方式修改最终生成的dom元素的实例,添加事件监听器,并设置数据绑定
    18                 },
    19                 compile : function(tElement, tAttrs, transclude) {
    20                     //在使用ng-repeat用编程的方式修改dom模版,从而实现一个指令跨越多个指令的特性。
    21                     //也可以返回一个link函数,可以用它来修改产生元素的示例
    22                     return {
    23                         pre : function preLink(scope, iElement, iAttrs,
    24                                 controller) {
    25                         },
    26                         post : function postLink(scope, iElement, iAttrs,
    27                                 controller) {
    28                         }
    29 
    30                     }
    31                 }
    32             };
    33         } ]);
  • 相关阅读:
    Shiro 学习笔记(Realm)
    Shiro 学习笔记(Authentication)
    Shiro 学习笔记(基本结构)
    POI 示例(导入,导出)
    SpringBoot 整合POI
    解决使用drf-haystack报错ImportError: cannot import name get_count
    python实现冒泡排序和插入排序
    九大排序算法总结(转)
    Djaong 数据库查询
    django session 和cookie的设置,获取和删除
  • 原文地址:https://www.cnblogs.com/goesby/p/angularjs.html
Copyright © 2011-2022 走看看