Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.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 在指令中的元素后追加模板_Javascript_Angularjs_Directive - Fatal编程技术网

Javascript 在指令中的元素后追加模板

Javascript 在指令中的元素后追加模板,javascript,angularjs,directive,Javascript,Angularjs,Directive,是否可以使用角度指令在某个元素后插入模板 我试图在文本区域后插入“example.html”模板 我砰的一声: 如您所见,HTML位于文本区域标记(dev工具)内 index.html <!DOCTYPE html> <html ng-app="plunker"> <head> <link rel="stylesheet" href="style.css"> <script data-require="angular.j

是否可以使用角度指令在某个元素后插入模板

我试图在文本区域后插入“example.html”模板
我砰的一声:
如您所见,HTML位于文本区域标记(dev工具)内

index.html

<!DOCTYPE html>
<html ng-app="plunker">

  <head>
    <link rel="stylesheet" href="style.css">
    <script data-require="angular.js@1.5.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js" data-semver="1.5.0"></script>
    <script src="script.js"></script>
  </head>

  <body ng-controller="MainCtrl">
    <form name="example-form">
        <textarea rows="3" id="goal" name="name" data-ng-model="model.name" example="10"></textarea>
        <example></example> <!-- Directive used here -->
    </form>
  </body>

</html>
<!DOCTYPE html>
<html ng-app="plunker">

  <head>
    <link rel="stylesheet" href="style.css">
    <script data-require="angular.js@1.5.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js" data-semver="1.5.0"></script>
    <script src="script.js"></script>
  </head>

  <body ng-controller="MainCtrl">
    <form name="example-form">
        <textarea rows="3" id="goal" name="name" data-ng-model="model.name" example="10"></textarea>
        <example></example> <!-- Directive used here -->
    </form>
  </body>

</html>

谢谢

您没有在index.html中的任何地方使用指令

<!DOCTYPE html>
<html ng-app="plunker">

  <head>
    <link rel="stylesheet" href="style.css">
    <script data-require="angular.js@1.5.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js" data-semver="1.5.0"></script>
    <script src="script.js"></script>
  </head>

  <body ng-controller="MainCtrl">
    <form name="example-form">
        <textarea rows="3" id="goal" name="name" data-ng-model="model.name" example="10"></textarea>
        <example></example> <!-- Directive used here -->
    </form>
  </body>

</html>
<!DOCTYPE html>
<html ng-app="plunker">

  <head>
    <link rel="stylesheet" href="style.css">
    <script data-require="angular.js@1.5.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js" data-semver="1.5.0"></script>
    <script src="script.js"></script>
  </head>

  <body ng-controller="MainCtrl">
    <form name="example-form">
        <textarea rows="3" id="goal" name="name" data-ng-model="model.name" example="10"></textarea>
        <example></example> <!-- Directive used here -->
    </form>
  </body>

</html>

我认为您需要使用transclude。