• 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>
  • 相关阅读:
    有关乞讨的人
    雪之国
    Direction
    Qt表格
    单例模式
    工作
    Qt模型model、视图view、代理
    Qt数据库sqlite
    QDateTime
    跨工程传输数据
  • 原文地址:https://www.cnblogs.com/zzq-include/p/4491898.html
Copyright © 2020-2023  润新知