2014-10-29 1 views
0

스크립트 태그 안에서 각도 표현식을 사용하려면 어떻게해야합니까?스크립트 태그 안에서 각도 표현을 사용합니다.

<div ng-include src="'modal-2.html'"></div> 
: 여기
.controller('TodoCtrl', function($scope, $ionicPopup, $timeout, $ionicModal, $ionicSideMenuDelegate) { 

    $scope.cardss = 
    {id:1, title:'Frank', src:'img/Frank.png',details:'This will be the products description!'}, 
    {id:2, title:'Generali', src:'img/Generali.png',details:'This will be the products description!'}, 
    {id:3, title:'John Lewis', src:'img/JohnLewis.png',details:'This will be the products description!'}, 
    ]; 

답변

0

당신이 템플릿을 사용하는 방법을 예입니다 : 여기
<script id="modal-2.html" type="text/ng-template"> 
<div class="modal transparent"> 
<div class="card"> 
<i class="icon ion-ios7-close close-modal" ng-click="closeModal(2)"></i> 
<div class="item item-divider"> 
{{card.title}} 
</div> 
<div class="item item-text-wrap"> 
{{card.details}} 
</div> 
</div> 
</div> 
</script> 

내 배열의 예입니다 여기 내 자바 스크립트 코드의 예입니다

또는 버튼 하나로 사용 :

<button ng-click="currentTpl='modal-2.html'">Show Modal</button> 
<div ng-include src="currentTpl"></div> 

템플릿의 표현식은 보통처럼 작동합니다.
여기에 example입니다.

+0

왜 downvote? 이것은 실제 예제이다. – friedi

1

부분 템플릿에는 AngularJS 표현식을 사용하지 않아도됩니다.

으로 이미 모델이 실제로 배열했다 - 그래서 당신은이 같은 ng-repeat를 사용하여 항목을 반복해야합니다 :

<ul> 
    <li ng-repeat="card in cards"> 
     Card id: {{card.id}} 
     Card title: {{card.title}} 
     Card details: {{card.details}} 
    </li> 
</ul> 

JSFiddle 예를 들어 작업을 참조하십시오.

관련 문제