[英]How to use Angular templating tags in Foundation for Apps?
I got this code from a Foundation for Apps page template here: Zurb 我是从Foundation for Apps页面模板获得此代码的: Zurb
the code: 编码:
<div class="accordion-item" ng-class="{'is-active': active}">
<!-- {{ varialbe }} -->
<div class="accordion-title" ng-click="activate()">{{ title }}</div>
<div class="accordion-content" ng-transclude></div>
</div>
I realize it's easy enough to use an accordion but that's really not my question. 我知道使用手风琴很容易,但这不是我的问题。 After a little research I found that the above code is using Angular tag templating. 经过一些研究,我发现上面的代码正在使用Angular标签模板。 However, I'm not sure how I can use this in my code Or why I would. 但是,我不确定如何在代码中使用它,或者为什么这样做。 This has to do with dynamically naming the title for what will be an active item in the accordion? 这与动态命名手风琴中活动项的标题有关吗? In what scenario would I define the title variable being used above? 在哪种情况下,我将定义上面使用的title变量? Should the content simply be placed in the div? 内容应该简单地放在div中吗?
This is the code from foundation-apps. 这是来自Foundation-apps的代码。
$templateCache.put('components/accordion/accordion-item.html',
'<div class="accordion-item" ng-class="{\'is-active\': active}">\n' +
' <div class="accordion-title" ng-click="activate()">{{ title }}</div>\n' +
' <div class="accordion-content" ng-transclude></div>\n' +
'</div>\n' +
'');
$templateCache.put puts the template in its memory and you can get to it with $templateCache.get('components/accordion/accordion-item.html').
$ templateCache.put将模板放入其内存中,您可以使用$templateCache.get('components/accordion/accordion-item.html').
If you want to use it in a directive, simply point your templateUrl to "components/accordion/accordion-item.html" 如果要在指令中使用它,只需将templateUrl指向“ components / accordion / accordion-item.html”
angular
.module('app')
.directive('myDirective', function() {
return {
templateUrl: 'components/accordion/accordion-item.html'
};
})
if you want to use your own template with foundation's javascript, simply use $templateCache.put(). 如果您想在Foundation的javascript中使用自己的模板,只需使用$ templateCache.put()。
$templateCache.put('components/accordion/accordion-item.html',
'my custom template');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.