首页 > 关于 ng-template 的引用问题

关于 ng-template 的引用问题


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

//b.html
<script type="text/ng-template" id="modal.tmpl.html">
    <div class="wrap-content reference">
        This is a modal.
    </div>
</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了呀。。


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

【热门文章】
【热门文章】