2013-10-16 3 views
1

AngularJS와 함께 일부 경고를 표시하려고합니다. 자세한 내용은 http://angular-ui.github.io/bootstrap/ - 경고 섹션을 참조하십시오. 나는 true로 설정 "쇼"속성이 알림 만 표시하도록 예제를 수정할 :AngularJS에 경고 표시

$scope.alerts = [ 
    { type: 'error', msg: 'Oh snap! Change a few things up and try submitting again.', show: true }, 
    { type: 'success', msg: 'Well done! You successfully read this important alert message.', show: false } 
    ]; 

내가 ng-show="alert.show"을 추가 한 경고 태그를하지만, 어떤 경고를 표시하지 않는 것 같다. 여기에서 코드를 찾을 수 있습니다 : http://plnkr.co/edit/Qbv4A9u1SnQeJy9o81lK?p=preview.

내가 잘못 했습니까? 미리 감사드립니다!

답변

4

ng-repeatng-show을 부모 div로 이동하십시오.

<div ng-controller="AlertDemoCtrl"> 
    <div ng-repeat="alert in alerts" ng-show="alert.show"> 
    <alert type="alert.type" close="closeAlert($index)">{{alert.msg}}</alert> 
    </div> 
    <button class='btn' ng-click="addAlert()">Add Alert</button> 
</div> 

ng-show 내가 UI 부트 스트랩에서 alert 지시어를 손에 작동하지 않습니다 회의적 그 자체로 지시어이다.

Modified Plunker

+0

위대한. 같은 문제가 있었는데 그것이 왜 효과가 없었는지 궁금해했다. – zszep