zoukankan      html  css  js  c++  java
  • AngularJS自定义指令之可选参数replace

    replace是一个可选参数,如果设置了这个参数,值必须为true,因为默认值为false。默认值意味着模板会被当作子元素插入到调用此指令的元素内部:

    如:

    <my-directive></my-directive>

    .directive("myDirective",function(){

               return {

                           template:"<h3>世上无难事,只怕有心人</h3>"

               }

    })

    调用指令之后的结果如下(这是默认replace为false时的情况):

    <my-directive>

          <h3>世上无难事,只怕有心人</h3>

    </my-directive>

    如果replace被设置为了true:

    .directive("myDirective",function(){

               return {

                     replace:true,

                     template:"<h3>世上无难事,只怕有心人</h3>"

               }

    })

    那么指令调用后的结果将是:

    <h3>世上无难事,只怕有心人</h3>

     

    注意:

    replace参数后必须有逗号(,),否则会出错。

  • 相关阅读:
    POJ1006(中国剩余定理)
    Ubuntu16.04安装jupiter
    OpenGL.tutorial06键盘和鼠标
    OpenGL.教程
    OpenGL.Qt532.cube
    Qt551.主窗体Margin
    Qt551.窗口滚动条
    Qt551.OpenGL.ZC简单例子
    Qt5OpenGL.顶点像素大小设置
    OpenGL.Tutorial03_Matrices_测试
  • 原文地址:https://www.cnblogs.com/jf-67/p/6404787.html
Copyright © 2011-2022 走看看