javascript - 关于 ng-template 的引用问题
怪我咯
怪我咯 2017-04-10 18:03:43
[JavaScript讨论组]

//a.html
<p controller="modalController">
    <a ng-click="openModal()"> open modal</a>
</p>

//b.html
<script type="text/ng-template" id="modal.tmpl.html">
    <p class="wrap-content reference">
        This is a modal.
    </p>
</script>

//c.js 支持es6语法
import './b.html';

var app = angular.module('app', ['ui.bootstrap']);
app.controller('modalController', ['$scope', '$uibModal', function($scope, $uibModal) {
    var modalInstance = $uibModal.open({
        templateUrl: 'modal.tmpl.html',
        size: 'md'
    });
}]);

上述写法不能打开模态窗,但是把b.html中的代码放入a.html中,就能够打开模态窗,请问这是为什么呢?

我在c.js文件中已经导入了b.html了呀。。

怪我咯
怪我咯

走同样的路,发现不同的人生

全部回复(1)
黄舟

这是因为angular不知道你的b.html,你可以看下$templatecache这个东西

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号