angularjs - When old label does not match new label add row to table -


i'm looking angularjs code.

when {{notification.label}} changes 1 value (the content of table database) add new row. can't work , because don't know how done. preferably close table , create new 1 because loop in tr i'm guessing not possible.

looking direction , maybe example. experimented if directive wasn't able compare old label new label.

<div id=postmodule data-ng-app="postmodule" data-ng-controller="postcontroller" data-ng-init="init()"     <form novalidate name="notificationform">         <table class="table table-bordered table-hover table-striped">             <tr data-ng-repeat="notification in post.notification | orderby : 'label'">                 <td>                     {{notification.label}}                 </td>                 <td>                     {{notification.vendor}}                 </td>                  <td>                     {{notification.product}}                 </td>                    <td>                     {{notification.version}}                 </td>                                                <td>                     {{notification.cve}}                 </td>                 <td>                     {{notification.cvsscore}}"                 </td>             </tr>         </table>     </form> </div> 

database:

notification.label || notification.vendor || notification.product expensive          || samsung             || galaxy expensive          || apple               || iphone budget             || huawai              || x budget             || huawai              || y 

i see (table)

notification.label || notification.vendor || notification.product expensive          || samsung             || galaxy expensive          || apple               || iphone  notification.label || notification.vendor || notification.product budget             || huawai              || x budget             || huawai              || y 

and better when 2 seperated tables

notification.label || notification.vendor || notification.product expensive          || samsung             || galaxy expensive          || apple               || iphone   notification.label || notification.vendor || notification.product budget             || huawai              || x budget             || huawai              || y 

you can use groupby achieve this.

// code goes here    angular.module('app',['angular.filter'])    .controller('maincontroller', function($scope) {             $scope.notifications = [{          label: 'expensive',          vendor: 'samsung             '      }, {          label: 'expensive',          vendor: 'sony'      }, {          label: 'expensive',          vendor: 'moto'      }, {          label: 'budget',          vendor: 'iphone'      }, {          label: 'budget',          vendor: 'x'      }];         });
.custom{  margin-bottom:0px !important;  }  .custom>tbody>tr>th  {     width: 50%;      float: left;      border: none !important;  }        
<!doctype html>  <html ng-app="app">      <head>      <link rel="stylesheet" href="style.css">      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>      <script src="//cdnjs.cloudflare.com/ajax/libs/angular-filter/0.5.1/angular-filter.js"></script>          <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">            <meta name="description" content="[groupby , sum example]"/>      <meta charset="utf-8">            <title>angular-filter - groupby , sum example</title>    </head>        <body>  <div ng-controller="maincontroller">  <ul ng-repeat="(key, value) in notifications | groupby: 'label'">    <table class="table table-bordered table-hover table-striped   custom">              <tr>                  <th>                      notification.label                  </th>                  <th>                      notification.vendor                  </th>                 </tr>  </table>              <table class="table table-bordered table-hover table-striped">              <tr data-ng-repeat="notification in value">                  <td>                      {{notification.label}}                  </td>                  <td>                      {{notification.vendor}}                  </td>                 </tr>          </table>          </ul>  </div>    </body>    </html>


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -