簡體   English   中英

在AngularJS警報上顯示ng-show

[英]ng-show on AngularJS alert

我試圖用AngularJS顯示一些警報,請參閱http://angular-ui.github.io/bootstrap/ - alert部分。 我想修改示例以僅顯示“show”屬性設置為true的警報:

  $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

我做錯了什么? 提前致謝!

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 Bootstrap的alert指令沒有合作。

改良的Plunker

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM