角标签渲染缓存模板" NG-包括SRC" [英] Angular Tabs render templates with caching in "ng-include src"
问题描述
我在含multitab观点角度MVC应用程序一直在努力。
我有一些templateURL选项卡的标签集
我已经做了这就像
$ scope.templateUrl ='';\r
VAR选项卡= $ scope.tabs =\r
[];\r
VAR控制器=这一点;\r
\r
this.selectTab =功能(标签)\r
{\r
$ templateCache.put(标签,tab.templateUrl);\r
angular.forEach(制表符,函数(TAB)\r
{\r
tab.selected = FALSE;\r
});\r
tab.selected = TRUE;\r
};\r
\r
this.setTabTemplate =功能(标签,templateUrl)\r
{\r
$ scope.templateUrl = $ templateCache.get(卡);\r
}\r
\r
this.addTab =功能(标签)\r
{\r
controller.selectTab(标签);\r
tabs.push(标签);\r
};
\r
< NG-包括SRC =templateUrl>< / NG-包括>
\r
我要缓存快速检索模板。
采用NG-包括和模板URL(即从春季调度的Servlet来)在其与$ templateCache不是为我工作。
请建议我怎么能达到同样的。
先谢谢了。
我已经包括了单独的NG-包括每个选项卡,它为我工作。
<&标签集GT;
<标签NG重复=,在tabsMenu标签主动=tab.active>
<制表标题> {{tab.title}}
<我NG-IF = tab.closableTab类=glyphicon glyphicon-删除closeTabIconNG点击=removeTab($指数)>< / I>
< /制表标题>
< NG-包括SRC =tab.url>< / NG-包括>
< /标签>
找到这个小提琴: https://jsfiddle.net/pawanFiddle/mwqty2sf/5/
感谢
I have been working in angular MVC application containing multitab views. I have a tabset with some templateURL tabs
What I have done for this is like
$scope.templateUrl = '';
var tabs = $scope.tabs =
[];
var controller = this;
this.selectTab = function(tab)
{
$templateCache.put(tab, tab.templateUrl);
angular.forEach(tabs, function(tab)
{
tab.selected = false;
});
tab.selected = true;
};
this.setTabTemplate = function(tab,templateUrl)
{
$scope.templateUrl = $templateCache.get(tab);
}
this.addTab = function(tab)
{
controller.selectTab(tab);
tabs.push(tab);
};
<ng-include src="templateUrl"></ng-include>
I have to cache the templates for fast retrieval. Using ng-include and template URL (that is coming from Spring Dispatcher Servlet) in it with $templateCache not working for me.
Please suggest how can I achieve the same.
Thanks in advance.
I have included separate ng-include for each tab and it worked for me.
<tabset>
<tab ng-repeat="tab in tabsMenu" active="tab.active">
<tab-heading> {{tab.title}}
<i ng-if =tab.closableTab class="glyphicon glyphicon-remove closeTabIcon" ng-click="removeTab($index)"></i>
</tab-heading>
<ng-include src="tab.url"></ng-include>
</tab>
find this fiddle : https://jsfiddle.net/pawanFiddle/mwqty2sf/5/
Thanks
这篇关于角标签渲染缓存模板&QUOT; NG-包括SRC&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!