Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.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 在Angular中,我可以从模板url中转写内容吗?_Javascript_Angularjs_Angularjs Directive - Fatal编程技术网

Javascript 在Angular中,我可以从模板url中转写内容吗?

Javascript 在Angular中,我可以从模板url中转写内容吗?,javascript,angularjs,angularjs-directive,Javascript,Angularjs,Angularjs Directive,我想从模板url中转移内容,而不是从指令标记的主体中 以模态为例,您可以看到需要使用模态指令为模态包装器标记声明模板url,但是对于转包内容,而不是从指令标记(某些模态可能具有广泛的标记)中获取该内容。我希望使用模板url来提供转包内容。因此,为组件提供了更干净的抽象层 i、 e homeView.html <my-modal transclude-content="profile"></my-modal> <div class="modal"> <

我想从模板url中转移内容,而不是从指令标记的主体中

以模态为例,您可以看到需要使用模态指令为模态包装器标记声明模板url,但是对于转包内容,而不是从指令标记(某些模态可能具有广泛的标记)中获取该内容。我希望使用模板url来提供转包内容。因此,为组件提供了更干净的抽象层

i、 e

homeView.html

<my-modal transclude-content="profile"></my-modal>
<div class="modal">
  <div class="modal-controls">
    <span class="minimize">-</span>
    <span class="close">x</span>
  </div>
  <div class="modal-body" ng-transclude>
  </div>
</div>
modalView.html

<my-modal transclude-content="profile"></my-modal>
<div class="modal">
  <div class="modal-controls">
    <span class="minimize">-</span>
    <span class="close">x</span>
  </div>
  <div class="modal-body" ng-transclude>
  </div>
</div>

-
x

答案很简单

筑巢你的指令

<modal-window>
   <user-profile></user-profile>
</modal-window>


看看这个答案,我认为这是goSpoke太早的方式,这个答案的问题在于它本质上是实现动态templateUrl的一种方式,而我需要从两个templateUrl中提取内容,一个用于指令shell,另一个用于转移shell中的内容。。。尽管这可能是朝着解决方案的正确方向发展的一点