반응형
Angular 내에서 재사용 가능한 스니펫을 수행할 수 있습니까?JS 템플릿?
같은 코드 조각을 몇 번이고 반복하고 있는 것을 알 수 있습니다. 앵글에서 이런 것을 할 수 있을까요?JS:
<div ng-snippet="mySnippet">
This is a snippet
</div>
<div ng-snippet="anotherSnippet">
Yet another snippet!!
</div>
<ng:include src="anotherSnippet">
<ng:include src="anotherSnippet">
<ng:include src="mySnippet">
위의 출력은 다음과 같습니다.
Yet another snippet!!
Yet another snippet!!
This is a snippet
반드시 이 "ng:include" 솔루션이나 패턴을 찾는 것이 아니라 템플릿의 반복을 줄일 수 있는 방법을 찾고 있습니다.
<script type='text/ng-template' id="mySnippet">
This is a snippet
</script>
<script type='text/ng-template' id="anotherSnippet">
Yet another snippet!!
</script>
<ng-include src="'anotherSnippet'"></ng-include>
<ng-include src="'anotherSnippet'"></ng-include>
<ng-include src="'mySnippet'"></ng-include>
이게 네가 원하는 거야
스크립트 및 ng-include 문서.
지시문을 사용하려는 것처럼 들리네요.다음은 간단한 예를 제시하겠습니다.http://jsfiddle.net/gyF6V/1/
언급URL : https://stackoverflow.com/questions/12698796/is-it-possible-to-do-reusable-snippets-within-angularjs-templates
반응형
'programing' 카테고리의 다른 글
| JSONObject에서 nameValuePairs 키를 삭제하려면 어떻게 해야 합니까? (0) | 2023.02.28 |
|---|---|
| Spring REST API에서 HTTP 코드 200을 반환한다. (0) | 2023.02.28 |
| AngularJS UI 라우터가 작동하지 않음 (0) | 2023.02.28 |
| JSON 날짜에서 Java 날짜로? (0) | 2023.02.28 |
| oracle varchar to number (0) | 2023.02.28 |