Angular js - Show message if ng-repeat is empty

后端 未结 7 2011
别那么骄傲
别那么骄傲 2020-12-13 19:08

The following AngularJS application is working with ng-repeat and an applied filter. A certain applied filter leaves no values left. How can I display a notification?

<
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 19:35

    I recently faced the same kind of problems.. I had three filters and one orderBy in the ng-repeat and wanted to show some emptyList Messages....
    The above solutions didnot work..so I made one out of my own.

    • Made the emptymsg as background div and the mainContainer as top div..
    • The emptyMsg div will always be shown, so whenever there is no value in list.. the emptyMsg will be the only div showing. PS: the code snippet wont run..because the additional libraries are not added.. This is just to give you an idea!
      //empty msg....
      .emptyMsg{
          position: absolute;
          left: 0;right: 0;
          margin: auto;
          color: gray;
          text-align: center;
          font-size:3.0em;
          z-index: 0;
      }
      .activityItem {
          margin: 0px !important;
          padding: 0px !important;
          border: 0px !important;
      }
      .mainContainer {
          z-index: 999;
          width: 100%;
          height: 40px;
          left: 0px;
          margin-top: 10px;
          display: inline-block;
      }

      List of Activities

      No Activities found!
      {{activity.energy}}%

提交回复
热议问题