zoukankan      html  css  js  c++  java
  • angularJS自定义指令模板替换

     1 <html>
     2 <head>
     3     <meta charset="utf-8"/>
     4     <title></title>
     5 </head>
     6 <body ng-app="components">
     7 <myelement>
     8     <h1>哈哈</h1>
     9 </myelement>
    10 </body>
    11 <script src="angular.js"></script>
    12 <script>
    13     var app= angular.module('components', []);
    14     app.directive('myelement', function() {
    15         return {
    16             restrict: 'AE',//自定义属性和Dom节点
    17             transclude: true,//将自定义指令内部原有的节点保留(这里注意,自定义指令中的内容在模板中必须有父节点)
    18             scope: {},
    19             templateUrl:"templates/templateOther.html",
    20             replace: true,//全部替换
    21             link:function(scope,element,attr){
    22                 element.bind("click",function(){
    23                     alert(1);
    24                 })
    25             }
    26         };
    27     });
    28 </script>
    29 </html>
  • 相关阅读:
    什么是云安全
    VMWare vForum 2013看点
    循环和数据的操作命令
    程序交互
    数据类型
    基础变量
    模块和包
    ['hello', 'sb']正则表达式
    os模块
    内置函数
  • 原文地址:https://www.cnblogs.com/zzq-include/p/4491898.html
Copyright © 2011-2022 走看看