Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Don';t从角度指令显示包装器_Javascript_Angularjs - Fatal编程技术网

Javascript Don';t从角度指令显示包装器

Javascript Don';t从角度指令显示包装器,javascript,angularjs,Javascript,Angularjs,我有一个角度指示。当我在页面上调用它时,它仍然显示外部包装。我怎样才能去掉这个包装纸 directions.js myApp.directive('myThingy', function(){ return { template: "<div>HELLO!</div>" } }); myApp.directive('myThingy',function(){ 返回{ 模板:“你好!” } }); my_page.html <html>

我有一个角度指示。当我在页面上调用它时,它仍然显示外部包装。我怎样才能去掉这个包装纸

directions.js

myApp.directive('myThingy', function(){
  return {
    template: "<div>HELLO!</div>"
  }
});
myApp.directive('myThingy',function(){
返回{
模板:“你好!”
}
});
my_page.html

<html>
  <body>
    <my-thingy></my-thingy>
  </body>
</html>

浏览器中的DOM:

<html>
  <body>
    <my-thingy>
      <div>HELLO!</div>
    </my-thingy>
  </body>
</html>
<html>
  <body>
    <div>HELLO!</div>
  </body>
</html>

你好
如何去掉那些
标记,只显示指令的结果

所需的DOM(没有my thingy标记):

<html>
  <body>
    <my-thingy>
      <div>HELLO!</div>
    </my-thingy>
  </body>
</html>
<html>
  <body>
    <div>HELLO!</div>
  </body>
</html>

你好

添加选项
替换

myApp.directive('myThingy', function(){
  return {
    replace: true,
    template: "<div>HELLO!</div>"
  }
});
myApp.directive('myThingy',function(){
返回{
替换:正确,
模板:“你好!”
}
});