主jsp:
<div>
<jsp:include page='/jsp/pnPanel.jsp'/>
</div>
pnPanel.jsp:
<div id="pnApp" ng-controller="pnController">
<div>
<a href="#" ng-click="loadPopup('cc');">
<font size="2" color="#cc6600">
<b>CC:</b>
</font>
</a>
</div>
<ng-include src="popupurl"></ng-include>
</div>
<script>
angular.element(document.getElementById("pnApp")).ready(function() {
angular.bootstrap(document.getElementById("pnApp"), ["pnApp"]);
});
var pnApp= angular.module('pnApp', []);
pnApp.config(function($controllerProvider, $provide, $compileProvider, $filterProvider, $httpProvider) {
// to keep the older references.
pnApp._controller = pnApp.controller;
pnApp._service = pnApp.service;
pnApp._factory = pnApp.factory;
pnApp._value = pnApp.value;
pnApp._directive = pnApp.directive;
// Lazy loading for controller.
pnApp.controller = function(name, constructor) {
$controllerProvider.register(name, constructor);
return(this);
};
// Lazy loading for service.
pnApp.service = function(name, constructor) {
$provide.service(name, constructor);
return(this);
};
// Lazy loading for factory.
pnApp.factory = function(name, factory) {
$provide.factory(name, factory);
return(this);
};
// Lazy loading for value.
pnApp.value = function(name, value) {
$provide.value(name, value);
return(this);
};
// Lazy loading for directive.
pnApp.directive = function(name, factory) {
$compileProvider.directive(name, factory);
return(this);
};
// Lazy loading for filter
pnApp.filter = function(name, filter) {
$filterProvider.register(name, filter);
return(this);
};
//initialize get if not there
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
}
//disable IE ajax request caching
$httpProvider.defaults.headers.get['If-Modified-Since'] = '0';
});
pnApp.controller('pnController', function($scope) {
$scope.loadPopup = function(pnSectionName) {
$scope.popupurl = "";
url = getUrl(pnSectionName);
$scope.popupurl = url;
};
};
</script>
在 $ scope.loadPopup 方法调用时,会填充 ng-include 的网址,并且会发生jsp调用,该调用具有自己的控制器并包含了所需的js文件jsp调用和它中存在的模态打开。这个jsp有一个隐藏在关闭状态的模式。但是当我再次点击链接时它不再使用相同的URL进行jsp调用。我甚至尝试清除缓存使用 $ templateCache ,如下所示。但是没有用。
pnApp.controller('pnController', function($scope,$templateCache) {
$scope.loadPopup = function(pnSectionName){
url = getUrl(pnSectionName);
$templateCache.remove(url);
$scope.popupurl = "";
$scope.popupurl = url;
};
};
但是当我在网址上附加一个随机数时,它就可以了。我不想附加随机数。为什么它不适用于 $ templateCache.remove(url)。