zoukankan      html  css  js  c++  java
  • Angularjs_directive_Demo

    1.文件列表

    2.dTest01.html

     1 <!doctype html>
     2 <html ng-app="mymy">
     3   <head>
     4       <meta  charset="UTF-8" >
     5       <script src="angular.js"></script>
     6       <script src="dTest01.js"></script>      
     7   </head>
     8   
     9   
    10 <body>     
    11    <div hello    ></div>
    12    <hello></hello>
    13    
    14    <xxh></xxh>
    15    <div  xxh></div>
    16 </body>
    17 
    18 
    19 </html>

    3.dTest01.js

     1 angular.module( "mymy", [] )
     2 
     3     .run(function($templateCache){
     4         $templateCache.put('hello.html','<div>hello everyOne!!</div>');
     5     })
     6 
     7 
     8     .directive( "hello" , function($templateCache){
     9       
    10       return {
    11           restrict: 'AE',
    12           template: $templateCache.get('hello.html'),
    13           replace: true
    14           
    15       }
    16       
    17       
    18     })
    19     
    20     .directive( "xxh" , function($templateCache){
    21       
    22       return {
    23           restrict: 'AE',
    24           template: $templateCache.get('hello.html'),
    25           replace: true
    26           
    27       }
    28       
    29       
    30     })

    4.hello.html

    1 <h1>wahaha</h1>

    PS:今天被谷歌浏览器坑了,调用templateUrl命令的时候,谷歌浏览器加载报错。火狐浏览器却能正常运行。

  • 相关阅读:
    P1495 曹冲养猪
    luoguP4281[AHOI2008]紧急集合 / 聚会
    NOIP1997 代数表达式
    luogu P3709大爷的字符串题
    luoguP3912 素数个数
    POJ 1065 Wooden Sticks
    POJ 1063 Flip and Shift
    POJ 1062 昂贵的聘礼
    POJ 1003 Hangover
    POJ 1001 Exponentiation
  • 原文地址:https://www.cnblogs.com/maduar/p/4694850.html
Copyright © 2011-2022 走看看