扫码关注官方订阅号
我有一个html文件a.html,如下:
a.html
我想利用angularjs在a.html嵌入另外一个b.html,如下:
b.html
希望的结果如下:
a.html b.html
请问如何实现?
认证高级PHP讲师
<p> a.html <bhtml></bhtml> </p>
angular .module('app') .directive('bhtml',function(){ return { templateUrl:'/b.html', restrict:'E', replace:true } })
这个差不多可以做到lz想要的效果了。但是比较麻烦一点,简单点的办法会多一个标签:
<p> a.html <p ng-include="/b.html"></p> </p>
结果:
<p> a.html <p ng-include="/b.html"> <p> b.html </p> </p> </p>
ng-include..
set transclued: true in your directive, and put transclude in your directive template where you want to embed another html template
transclued: true
transclude
<p> hello a <dv ng-include="b.html"></p> </p>
<p> hello b </p>
ui-router
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
这个差不多可以做到lz想要的效果了。但是比较麻烦一点,简单点的办法会多一个标签:
结果:
ng-include..
set
transclued: truein your directive, and puttranscludein your directive template where you want to embed another html templatea.html
b.html
ui-router