//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了呀。。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
这是因为angular不知道你的b.html,你可以看下$templatecache这个东西