AngularJS doesn't work with 'multiple' flag












0














I'm trying to filter some data from the select box. It works fine when I don't use the "multiple" flag. However, the idea here is to be able to select multiple environments and multiple applications and show it based the options I selected, but it is not working. I tried in many different ways, but I didn't find what I'm missing. Can someone help me here?



Here are the files which I'm using.



monitoring.html



<div ng-controller="monitoring" class="md-padding selectdemoOptionGroups" ng-cloak="" ng-app="monitor">
<div>
<h1 class="md-title">Monitoring</h1>
<div layout="row">

<md-input-container style="margin-right: 10px;">
<label>Segments</label>
<md-select ng-model="segment" >
<md-option ng-repeat="segment in segments" value="{{segment}}">{{segment}}</md-option>
</md-select>
</md-input-container>

<md-input-container>
<label>Environments</label>
<md-select ng-model="selectedEnvironments" multiple>
<md-optgroup label="environments">
<md-option ng-value="environment.name" ng-repeat="environment in environments | filter: {category: 'env' }">{{environment.name}}</md-option>
</md-optgroup>
</md-select>
</md-input-container>

<md-input-container>
<label>Applications</label>
<md-select ng-model="selectedApplications" multiple="">
<md-optgroup label="application">
<md-option ng-value="application.name" ng-repeat="application in applications | filter: {category: 'app' } ">{{application.name}}</md-option>
</md-optgroup>
</md-select>
</md-input-container>

<button ng-click="clear()" style="width: 55px; height: 50px;" id="iconTextButton">Clear</button>
<button style="width: 55px; height: 50px;" id="iconTextButton">Run</button>
</div>

<div class="md-card container-shadow" style="margin:15px">
<div class="card-header4">
Monitoring page1 for {{segment}}
</div>
<table id="grid422">
<colgroup>
<col style="width:830px" />
<col style="width:130px" />
<col style="width:130px" />
<col style="width:130px" />
</colgroup>
<thead align="left">
<tr>
<th >Application</th>
<th>Environment</th>
<th >StatusUP</th>
<th>StatusDown</th>
</tr>
</thead>
<tbody align="left" >
<tr ng-repeat="todo in todos | filter:segment | filter:selectedEnvironments | orderBy: 'application' ">
<td>{{todo.application}}</td>
<td>{{todo.environment}}</td>
<td>{{todo.statusUp}}</td>
<td>{{todo.statusDown}}<td>
</tr>
</tbody>
</table>
</div></div>


monitoring.js



(function (angular) {
angular
.module('monitor')
.controller('monitoring', function ($scope, $http) {
$scope.segments = [
"SegmentA",
"SegmentB",
"SegmentC"
];
$scope.selectedSegments = ;
$scope.printSelectedSegments = function printSelectedSegments() {
return this.selectedSegments.join('');
};

$scope.environments = [
{ category: 'env', name: 'ENV1' },
{ category: 'env', name: 'ENV2' },
{ category: 'env', name: 'ENV3' },
{ category: 'env', name: 'ENV4' }
];
$scope.selectedEnvironments = ;
$scope.printSelectedEnvironments = function printSelectedEnvironments() {
var numberOfEnvironments = this.selectedEnvironments.length;


if (numberOfEnvironments > 1) {
var needsOxfordComma = numberOfEnvironments > 2;
var lastEnvironmentConjunction = (needsOxfordComma ? ',' : '') + ' and ';
var lastEnvironment = lastEnvironmentConjunction +
this.selectedEnvironments[this.selectedEnvironments.length - 1];
return this.selectedEnvironments.slice(0, -1).join(', ') + lastEnvironment;
}
return this.selectedEnvironments.join('');
};

$scope.applications = [
{ category: 'app', name: 'App1' },
{ category: 'app', name: 'App2' },
{ category: 'app', name: 'App3' },
{ category: 'app', name: 'App4' }
];
$scope.selectedApplications = ;
$scope.printSelectedApplications = function printSelectedApplications() {
var numberOfApplications = this.selectedApplications.length;

if (numberOfApplications > 1) {
var needsOxfordComma = numberOfApplications > 2;
var lastApplicationConjunction = (needsOxfordComma ? ',' : '') + ' and ';
var lastApplication = lastApplicationConjunction +
this.selectedApplications[this.selectedApplications.length - 1];
return this.selectedApplications.slice(0, -1).join(', ') + lastApplication;
}
return this.selectedApplications.join('');
};

$scope.todos = [
{"segment":"SegmentA","application":"App1","environment":"ENV1","statusUp":57,"statusDown":"13"},{"segment":"SegmentB","application":"App2","environment":"ENV2","statusUp":12,"statusDown":"33"},{"segment":"SegmentC","application":"App3","environment":"ENV4","statusUp":357,"statusDown":"133"},{"segment":"SegmentA","application":"App1","environment":"ENV1","statusUp":57,"statusDown":"13"},{"segment":"SegmentB","application":"App2","environment":"ENV1","statusUp":12,"statusDown":"33"},{"segment":"SegmentC","application":"App3","environment":"ENV3","statusUp":333,"statusDown":"213"},{"segment":"SegmentB","application":"App1","environment":"ENV4","statusUp":357,"statusDown":"133"},{"segment":"SegmentC","application":"App2","environment":"ENV2","statusUp":57,"statusDown":"13"}
];

});
})(angular);









share|improve this question



























    0














    I'm trying to filter some data from the select box. It works fine when I don't use the "multiple" flag. However, the idea here is to be able to select multiple environments and multiple applications and show it based the options I selected, but it is not working. I tried in many different ways, but I didn't find what I'm missing. Can someone help me here?



    Here are the files which I'm using.



    monitoring.html



    <div ng-controller="monitoring" class="md-padding selectdemoOptionGroups" ng-cloak="" ng-app="monitor">
    <div>
    <h1 class="md-title">Monitoring</h1>
    <div layout="row">

    <md-input-container style="margin-right: 10px;">
    <label>Segments</label>
    <md-select ng-model="segment" >
    <md-option ng-repeat="segment in segments" value="{{segment}}">{{segment}}</md-option>
    </md-select>
    </md-input-container>

    <md-input-container>
    <label>Environments</label>
    <md-select ng-model="selectedEnvironments" multiple>
    <md-optgroup label="environments">
    <md-option ng-value="environment.name" ng-repeat="environment in environments | filter: {category: 'env' }">{{environment.name}}</md-option>
    </md-optgroup>
    </md-select>
    </md-input-container>

    <md-input-container>
    <label>Applications</label>
    <md-select ng-model="selectedApplications" multiple="">
    <md-optgroup label="application">
    <md-option ng-value="application.name" ng-repeat="application in applications | filter: {category: 'app' } ">{{application.name}}</md-option>
    </md-optgroup>
    </md-select>
    </md-input-container>

    <button ng-click="clear()" style="width: 55px; height: 50px;" id="iconTextButton">Clear</button>
    <button style="width: 55px; height: 50px;" id="iconTextButton">Run</button>
    </div>

    <div class="md-card container-shadow" style="margin:15px">
    <div class="card-header4">
    Monitoring page1 for {{segment}}
    </div>
    <table id="grid422">
    <colgroup>
    <col style="width:830px" />
    <col style="width:130px" />
    <col style="width:130px" />
    <col style="width:130px" />
    </colgroup>
    <thead align="left">
    <tr>
    <th >Application</th>
    <th>Environment</th>
    <th >StatusUP</th>
    <th>StatusDown</th>
    </tr>
    </thead>
    <tbody align="left" >
    <tr ng-repeat="todo in todos | filter:segment | filter:selectedEnvironments | orderBy: 'application' ">
    <td>{{todo.application}}</td>
    <td>{{todo.environment}}</td>
    <td>{{todo.statusUp}}</td>
    <td>{{todo.statusDown}}<td>
    </tr>
    </tbody>
    </table>
    </div></div>


    monitoring.js



    (function (angular) {
    angular
    .module('monitor')
    .controller('monitoring', function ($scope, $http) {
    $scope.segments = [
    "SegmentA",
    "SegmentB",
    "SegmentC"
    ];
    $scope.selectedSegments = ;
    $scope.printSelectedSegments = function printSelectedSegments() {
    return this.selectedSegments.join('');
    };

    $scope.environments = [
    { category: 'env', name: 'ENV1' },
    { category: 'env', name: 'ENV2' },
    { category: 'env', name: 'ENV3' },
    { category: 'env', name: 'ENV4' }
    ];
    $scope.selectedEnvironments = ;
    $scope.printSelectedEnvironments = function printSelectedEnvironments() {
    var numberOfEnvironments = this.selectedEnvironments.length;


    if (numberOfEnvironments > 1) {
    var needsOxfordComma = numberOfEnvironments > 2;
    var lastEnvironmentConjunction = (needsOxfordComma ? ',' : '') + ' and ';
    var lastEnvironment = lastEnvironmentConjunction +
    this.selectedEnvironments[this.selectedEnvironments.length - 1];
    return this.selectedEnvironments.slice(0, -1).join(', ') + lastEnvironment;
    }
    return this.selectedEnvironments.join('');
    };

    $scope.applications = [
    { category: 'app', name: 'App1' },
    { category: 'app', name: 'App2' },
    { category: 'app', name: 'App3' },
    { category: 'app', name: 'App4' }
    ];
    $scope.selectedApplications = ;
    $scope.printSelectedApplications = function printSelectedApplications() {
    var numberOfApplications = this.selectedApplications.length;

    if (numberOfApplications > 1) {
    var needsOxfordComma = numberOfApplications > 2;
    var lastApplicationConjunction = (needsOxfordComma ? ',' : '') + ' and ';
    var lastApplication = lastApplicationConjunction +
    this.selectedApplications[this.selectedApplications.length - 1];
    return this.selectedApplications.slice(0, -1).join(', ') + lastApplication;
    }
    return this.selectedApplications.join('');
    };

    $scope.todos = [
    {"segment":"SegmentA","application":"App1","environment":"ENV1","statusUp":57,"statusDown":"13"},{"segment":"SegmentB","application":"App2","environment":"ENV2","statusUp":12,"statusDown":"33"},{"segment":"SegmentC","application":"App3","environment":"ENV4","statusUp":357,"statusDown":"133"},{"segment":"SegmentA","application":"App1","environment":"ENV1","statusUp":57,"statusDown":"13"},{"segment":"SegmentB","application":"App2","environment":"ENV1","statusUp":12,"statusDown":"33"},{"segment":"SegmentC","application":"App3","environment":"ENV3","statusUp":333,"statusDown":"213"},{"segment":"SegmentB","application":"App1","environment":"ENV4","statusUp":357,"statusDown":"133"},{"segment":"SegmentC","application":"App2","environment":"ENV2","statusUp":57,"statusDown":"13"}
    ];

    });
    })(angular);









    share|improve this question

























      0












      0








      0







      I'm trying to filter some data from the select box. It works fine when I don't use the "multiple" flag. However, the idea here is to be able to select multiple environments and multiple applications and show it based the options I selected, but it is not working. I tried in many different ways, but I didn't find what I'm missing. Can someone help me here?



      Here are the files which I'm using.



      monitoring.html



      <div ng-controller="monitoring" class="md-padding selectdemoOptionGroups" ng-cloak="" ng-app="monitor">
      <div>
      <h1 class="md-title">Monitoring</h1>
      <div layout="row">

      <md-input-container style="margin-right: 10px;">
      <label>Segments</label>
      <md-select ng-model="segment" >
      <md-option ng-repeat="segment in segments" value="{{segment}}">{{segment}}</md-option>
      </md-select>
      </md-input-container>

      <md-input-container>
      <label>Environments</label>
      <md-select ng-model="selectedEnvironments" multiple>
      <md-optgroup label="environments">
      <md-option ng-value="environment.name" ng-repeat="environment in environments | filter: {category: 'env' }">{{environment.name}}</md-option>
      </md-optgroup>
      </md-select>
      </md-input-container>

      <md-input-container>
      <label>Applications</label>
      <md-select ng-model="selectedApplications" multiple="">
      <md-optgroup label="application">
      <md-option ng-value="application.name" ng-repeat="application in applications | filter: {category: 'app' } ">{{application.name}}</md-option>
      </md-optgroup>
      </md-select>
      </md-input-container>

      <button ng-click="clear()" style="width: 55px; height: 50px;" id="iconTextButton">Clear</button>
      <button style="width: 55px; height: 50px;" id="iconTextButton">Run</button>
      </div>

      <div class="md-card container-shadow" style="margin:15px">
      <div class="card-header4">
      Monitoring page1 for {{segment}}
      </div>
      <table id="grid422">
      <colgroup>
      <col style="width:830px" />
      <col style="width:130px" />
      <col style="width:130px" />
      <col style="width:130px" />
      </colgroup>
      <thead align="left">
      <tr>
      <th >Application</th>
      <th>Environment</th>
      <th >StatusUP</th>
      <th>StatusDown</th>
      </tr>
      </thead>
      <tbody align="left" >
      <tr ng-repeat="todo in todos | filter:segment | filter:selectedEnvironments | orderBy: 'application' ">
      <td>{{todo.application}}</td>
      <td>{{todo.environment}}</td>
      <td>{{todo.statusUp}}</td>
      <td>{{todo.statusDown}}<td>
      </tr>
      </tbody>
      </table>
      </div></div>


      monitoring.js



      (function (angular) {
      angular
      .module('monitor')
      .controller('monitoring', function ($scope, $http) {
      $scope.segments = [
      "SegmentA",
      "SegmentB",
      "SegmentC"
      ];
      $scope.selectedSegments = ;
      $scope.printSelectedSegments = function printSelectedSegments() {
      return this.selectedSegments.join('');
      };

      $scope.environments = [
      { category: 'env', name: 'ENV1' },
      { category: 'env', name: 'ENV2' },
      { category: 'env', name: 'ENV3' },
      { category: 'env', name: 'ENV4' }
      ];
      $scope.selectedEnvironments = ;
      $scope.printSelectedEnvironments = function printSelectedEnvironments() {
      var numberOfEnvironments = this.selectedEnvironments.length;


      if (numberOfEnvironments > 1) {
      var needsOxfordComma = numberOfEnvironments > 2;
      var lastEnvironmentConjunction = (needsOxfordComma ? ',' : '') + ' and ';
      var lastEnvironment = lastEnvironmentConjunction +
      this.selectedEnvironments[this.selectedEnvironments.length - 1];
      return this.selectedEnvironments.slice(0, -1).join(', ') + lastEnvironment;
      }
      return this.selectedEnvironments.join('');
      };

      $scope.applications = [
      { category: 'app', name: 'App1' },
      { category: 'app', name: 'App2' },
      { category: 'app', name: 'App3' },
      { category: 'app', name: 'App4' }
      ];
      $scope.selectedApplications = ;
      $scope.printSelectedApplications = function printSelectedApplications() {
      var numberOfApplications = this.selectedApplications.length;

      if (numberOfApplications > 1) {
      var needsOxfordComma = numberOfApplications > 2;
      var lastApplicationConjunction = (needsOxfordComma ? ',' : '') + ' and ';
      var lastApplication = lastApplicationConjunction +
      this.selectedApplications[this.selectedApplications.length - 1];
      return this.selectedApplications.slice(0, -1).join(', ') + lastApplication;
      }
      return this.selectedApplications.join('');
      };

      $scope.todos = [
      {"segment":"SegmentA","application":"App1","environment":"ENV1","statusUp":57,"statusDown":"13"},{"segment":"SegmentB","application":"App2","environment":"ENV2","statusUp":12,"statusDown":"33"},{"segment":"SegmentC","application":"App3","environment":"ENV4","statusUp":357,"statusDown":"133"},{"segment":"SegmentA","application":"App1","environment":"ENV1","statusUp":57,"statusDown":"13"},{"segment":"SegmentB","application":"App2","environment":"ENV1","statusUp":12,"statusDown":"33"},{"segment":"SegmentC","application":"App3","environment":"ENV3","statusUp":333,"statusDown":"213"},{"segment":"SegmentB","application":"App1","environment":"ENV4","statusUp":357,"statusDown":"133"},{"segment":"SegmentC","application":"App2","environment":"ENV2","statusUp":57,"statusDown":"13"}
      ];

      });
      })(angular);









      share|improve this question













      I'm trying to filter some data from the select box. It works fine when I don't use the "multiple" flag. However, the idea here is to be able to select multiple environments and multiple applications and show it based the options I selected, but it is not working. I tried in many different ways, but I didn't find what I'm missing. Can someone help me here?



      Here are the files which I'm using.



      monitoring.html



      <div ng-controller="monitoring" class="md-padding selectdemoOptionGroups" ng-cloak="" ng-app="monitor">
      <div>
      <h1 class="md-title">Monitoring</h1>
      <div layout="row">

      <md-input-container style="margin-right: 10px;">
      <label>Segments</label>
      <md-select ng-model="segment" >
      <md-option ng-repeat="segment in segments" value="{{segment}}">{{segment}}</md-option>
      </md-select>
      </md-input-container>

      <md-input-container>
      <label>Environments</label>
      <md-select ng-model="selectedEnvironments" multiple>
      <md-optgroup label="environments">
      <md-option ng-value="environment.name" ng-repeat="environment in environments | filter: {category: 'env' }">{{environment.name}}</md-option>
      </md-optgroup>
      </md-select>
      </md-input-container>

      <md-input-container>
      <label>Applications</label>
      <md-select ng-model="selectedApplications" multiple="">
      <md-optgroup label="application">
      <md-option ng-value="application.name" ng-repeat="application in applications | filter: {category: 'app' } ">{{application.name}}</md-option>
      </md-optgroup>
      </md-select>
      </md-input-container>

      <button ng-click="clear()" style="width: 55px; height: 50px;" id="iconTextButton">Clear</button>
      <button style="width: 55px; height: 50px;" id="iconTextButton">Run</button>
      </div>

      <div class="md-card container-shadow" style="margin:15px">
      <div class="card-header4">
      Monitoring page1 for {{segment}}
      </div>
      <table id="grid422">
      <colgroup>
      <col style="width:830px" />
      <col style="width:130px" />
      <col style="width:130px" />
      <col style="width:130px" />
      </colgroup>
      <thead align="left">
      <tr>
      <th >Application</th>
      <th>Environment</th>
      <th >StatusUP</th>
      <th>StatusDown</th>
      </tr>
      </thead>
      <tbody align="left" >
      <tr ng-repeat="todo in todos | filter:segment | filter:selectedEnvironments | orderBy: 'application' ">
      <td>{{todo.application}}</td>
      <td>{{todo.environment}}</td>
      <td>{{todo.statusUp}}</td>
      <td>{{todo.statusDown}}<td>
      </tr>
      </tbody>
      </table>
      </div></div>


      monitoring.js



      (function (angular) {
      angular
      .module('monitor')
      .controller('monitoring', function ($scope, $http) {
      $scope.segments = [
      "SegmentA",
      "SegmentB",
      "SegmentC"
      ];
      $scope.selectedSegments = ;
      $scope.printSelectedSegments = function printSelectedSegments() {
      return this.selectedSegments.join('');
      };

      $scope.environments = [
      { category: 'env', name: 'ENV1' },
      { category: 'env', name: 'ENV2' },
      { category: 'env', name: 'ENV3' },
      { category: 'env', name: 'ENV4' }
      ];
      $scope.selectedEnvironments = ;
      $scope.printSelectedEnvironments = function printSelectedEnvironments() {
      var numberOfEnvironments = this.selectedEnvironments.length;


      if (numberOfEnvironments > 1) {
      var needsOxfordComma = numberOfEnvironments > 2;
      var lastEnvironmentConjunction = (needsOxfordComma ? ',' : '') + ' and ';
      var lastEnvironment = lastEnvironmentConjunction +
      this.selectedEnvironments[this.selectedEnvironments.length - 1];
      return this.selectedEnvironments.slice(0, -1).join(', ') + lastEnvironment;
      }
      return this.selectedEnvironments.join('');
      };

      $scope.applications = [
      { category: 'app', name: 'App1' },
      { category: 'app', name: 'App2' },
      { category: 'app', name: 'App3' },
      { category: 'app', name: 'App4' }
      ];
      $scope.selectedApplications = ;
      $scope.printSelectedApplications = function printSelectedApplications() {
      var numberOfApplications = this.selectedApplications.length;

      if (numberOfApplications > 1) {
      var needsOxfordComma = numberOfApplications > 2;
      var lastApplicationConjunction = (needsOxfordComma ? ',' : '') + ' and ';
      var lastApplication = lastApplicationConjunction +
      this.selectedApplications[this.selectedApplications.length - 1];
      return this.selectedApplications.slice(0, -1).join(', ') + lastApplication;
      }
      return this.selectedApplications.join('');
      };

      $scope.todos = [
      {"segment":"SegmentA","application":"App1","environment":"ENV1","statusUp":57,"statusDown":"13"},{"segment":"SegmentB","application":"App2","environment":"ENV2","statusUp":12,"statusDown":"33"},{"segment":"SegmentC","application":"App3","environment":"ENV4","statusUp":357,"statusDown":"133"},{"segment":"SegmentA","application":"App1","environment":"ENV1","statusUp":57,"statusDown":"13"},{"segment":"SegmentB","application":"App2","environment":"ENV1","statusUp":12,"statusDown":"33"},{"segment":"SegmentC","application":"App3","environment":"ENV3","statusUp":333,"statusDown":"213"},{"segment":"SegmentB","application":"App1","environment":"ENV4","statusUp":357,"statusDown":"133"},{"segment":"SegmentC","application":"App2","environment":"ENV2","statusUp":57,"statusDown":"13"}
      ];

      });
      })(angular);






      angularjs angularjs-ng-repeat






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 at 1:42









      rrudnicki

      32




      32
























          2 Answers
          2






          active

          oldest

          votes


















          0














          You can create custom function for filter



          Updated code



          <tbody align="left">
          <tr ng-repeat="todo in todos | **filter: filterByGenres** | orderBy: 'application' ">
          <td>{{todo.application}}</td>
          <td>{{todo.environment}}</td>
          <td>{{todo.statusUp}}</td>
          <td>{{todo.statusDown}}
          <td>
          </tr>


          angular controller side code



              (function(angular) {
          angular
          .module('plunker', ['ngMaterial'])
          .controller('monitoring', function($scope, $http) {

          **$scope.filterByGenres = function(ele) {
          var res = true
          if ($scope.selectedEnvironments !== null && $scope.selectedEnvironments.length > 0) {
          if ($scope.selectedEnvironments.indexOf(ele.environment) == -1) {
          res = false;
          }
          }
          if ($scope.selectedApplications !== null && $scope.selectedApplications.length > 0) {
          if ($scope.selectedApplications.indexOf(ele.application) == -1) {
          res = false;
          }
          }
          return res;
          }**

          $scope.segments = [
          "SegmentA",
          "SegmentB",
          "SegmentC"
          ];
          ...


          Plunker here



          Thanks






          share|improve this answer





















          • Hi @Ajay thanks a lot, it work like a charm. Have a great day buddy!! :)
            – rrudnicki
            Nov 21 at 11:31



















          0














          I just run your source on codepen.io and nothing output, try included md then everything ok. So, please try use .module('monitor', ['ngMaterial']) and test again.






          share|improve this answer





















          • Hi incNick, I added the code in codepen.io, and added the ngMaterial, but for some reason, my code is not showing correct there. Here is what I am seeing: codepen.io/renato-rudnicki/pen/dQJLVZ
            – rrudnicki
            Nov 21 at 9:41










          • @rrudnicki it is your package reason, I can't sure v1.1.10/angular-material.js is ok for angular1.7.5. Please open material.angularjs.org Demo and click the CodePen icon, paste your source there.
            – incNick
            Nov 21 at 11:26











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404174%2fangularjs-doesnt-work-with-multiple-flag%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You can create custom function for filter



          Updated code



          <tbody align="left">
          <tr ng-repeat="todo in todos | **filter: filterByGenres** | orderBy: 'application' ">
          <td>{{todo.application}}</td>
          <td>{{todo.environment}}</td>
          <td>{{todo.statusUp}}</td>
          <td>{{todo.statusDown}}
          <td>
          </tr>


          angular controller side code



              (function(angular) {
          angular
          .module('plunker', ['ngMaterial'])
          .controller('monitoring', function($scope, $http) {

          **$scope.filterByGenres = function(ele) {
          var res = true
          if ($scope.selectedEnvironments !== null && $scope.selectedEnvironments.length > 0) {
          if ($scope.selectedEnvironments.indexOf(ele.environment) == -1) {
          res = false;
          }
          }
          if ($scope.selectedApplications !== null && $scope.selectedApplications.length > 0) {
          if ($scope.selectedApplications.indexOf(ele.application) == -1) {
          res = false;
          }
          }
          return res;
          }**

          $scope.segments = [
          "SegmentA",
          "SegmentB",
          "SegmentC"
          ];
          ...


          Plunker here



          Thanks






          share|improve this answer





















          • Hi @Ajay thanks a lot, it work like a charm. Have a great day buddy!! :)
            – rrudnicki
            Nov 21 at 11:31
















          0














          You can create custom function for filter



          Updated code



          <tbody align="left">
          <tr ng-repeat="todo in todos | **filter: filterByGenres** | orderBy: 'application' ">
          <td>{{todo.application}}</td>
          <td>{{todo.environment}}</td>
          <td>{{todo.statusUp}}</td>
          <td>{{todo.statusDown}}
          <td>
          </tr>


          angular controller side code



              (function(angular) {
          angular
          .module('plunker', ['ngMaterial'])
          .controller('monitoring', function($scope, $http) {

          **$scope.filterByGenres = function(ele) {
          var res = true
          if ($scope.selectedEnvironments !== null && $scope.selectedEnvironments.length > 0) {
          if ($scope.selectedEnvironments.indexOf(ele.environment) == -1) {
          res = false;
          }
          }
          if ($scope.selectedApplications !== null && $scope.selectedApplications.length > 0) {
          if ($scope.selectedApplications.indexOf(ele.application) == -1) {
          res = false;
          }
          }
          return res;
          }**

          $scope.segments = [
          "SegmentA",
          "SegmentB",
          "SegmentC"
          ];
          ...


          Plunker here



          Thanks






          share|improve this answer





















          • Hi @Ajay thanks a lot, it work like a charm. Have a great day buddy!! :)
            – rrudnicki
            Nov 21 at 11:31














          0












          0








          0






          You can create custom function for filter



          Updated code



          <tbody align="left">
          <tr ng-repeat="todo in todos | **filter: filterByGenres** | orderBy: 'application' ">
          <td>{{todo.application}}</td>
          <td>{{todo.environment}}</td>
          <td>{{todo.statusUp}}</td>
          <td>{{todo.statusDown}}
          <td>
          </tr>


          angular controller side code



              (function(angular) {
          angular
          .module('plunker', ['ngMaterial'])
          .controller('monitoring', function($scope, $http) {

          **$scope.filterByGenres = function(ele) {
          var res = true
          if ($scope.selectedEnvironments !== null && $scope.selectedEnvironments.length > 0) {
          if ($scope.selectedEnvironments.indexOf(ele.environment) == -1) {
          res = false;
          }
          }
          if ($scope.selectedApplications !== null && $scope.selectedApplications.length > 0) {
          if ($scope.selectedApplications.indexOf(ele.application) == -1) {
          res = false;
          }
          }
          return res;
          }**

          $scope.segments = [
          "SegmentA",
          "SegmentB",
          "SegmentC"
          ];
          ...


          Plunker here



          Thanks






          share|improve this answer












          You can create custom function for filter



          Updated code



          <tbody align="left">
          <tr ng-repeat="todo in todos | **filter: filterByGenres** | orderBy: 'application' ">
          <td>{{todo.application}}</td>
          <td>{{todo.environment}}</td>
          <td>{{todo.statusUp}}</td>
          <td>{{todo.statusDown}}
          <td>
          </tr>


          angular controller side code



              (function(angular) {
          angular
          .module('plunker', ['ngMaterial'])
          .controller('monitoring', function($scope, $http) {

          **$scope.filterByGenres = function(ele) {
          var res = true
          if ($scope.selectedEnvironments !== null && $scope.selectedEnvironments.length > 0) {
          if ($scope.selectedEnvironments.indexOf(ele.environment) == -1) {
          res = false;
          }
          }
          if ($scope.selectedApplications !== null && $scope.selectedApplications.length > 0) {
          if ($scope.selectedApplications.indexOf(ele.application) == -1) {
          res = false;
          }
          }
          return res;
          }**

          $scope.segments = [
          "SegmentA",
          "SegmentB",
          "SegmentC"
          ];
          ...


          Plunker here



          Thanks







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 at 9:36









          Ajay

          662




          662












          • Hi @Ajay thanks a lot, it work like a charm. Have a great day buddy!! :)
            – rrudnicki
            Nov 21 at 11:31


















          • Hi @Ajay thanks a lot, it work like a charm. Have a great day buddy!! :)
            – rrudnicki
            Nov 21 at 11:31
















          Hi @Ajay thanks a lot, it work like a charm. Have a great day buddy!! :)
          – rrudnicki
          Nov 21 at 11:31




          Hi @Ajay thanks a lot, it work like a charm. Have a great day buddy!! :)
          – rrudnicki
          Nov 21 at 11:31













          0














          I just run your source on codepen.io and nothing output, try included md then everything ok. So, please try use .module('monitor', ['ngMaterial']) and test again.






          share|improve this answer





















          • Hi incNick, I added the code in codepen.io, and added the ngMaterial, but for some reason, my code is not showing correct there. Here is what I am seeing: codepen.io/renato-rudnicki/pen/dQJLVZ
            – rrudnicki
            Nov 21 at 9:41










          • @rrudnicki it is your package reason, I can't sure v1.1.10/angular-material.js is ok for angular1.7.5. Please open material.angularjs.org Demo and click the CodePen icon, paste your source there.
            – incNick
            Nov 21 at 11:26
















          0














          I just run your source on codepen.io and nothing output, try included md then everything ok. So, please try use .module('monitor', ['ngMaterial']) and test again.






          share|improve this answer





















          • Hi incNick, I added the code in codepen.io, and added the ngMaterial, but for some reason, my code is not showing correct there. Here is what I am seeing: codepen.io/renato-rudnicki/pen/dQJLVZ
            – rrudnicki
            Nov 21 at 9:41










          • @rrudnicki it is your package reason, I can't sure v1.1.10/angular-material.js is ok for angular1.7.5. Please open material.angularjs.org Demo and click the CodePen icon, paste your source there.
            – incNick
            Nov 21 at 11:26














          0












          0








          0






          I just run your source on codepen.io and nothing output, try included md then everything ok. So, please try use .module('monitor', ['ngMaterial']) and test again.






          share|improve this answer












          I just run your source on codepen.io and nothing output, try included md then everything ok. So, please try use .module('monitor', ['ngMaterial']) and test again.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 at 4:06









          incNick

          35715




          35715












          • Hi incNick, I added the code in codepen.io, and added the ngMaterial, but for some reason, my code is not showing correct there. Here is what I am seeing: codepen.io/renato-rudnicki/pen/dQJLVZ
            – rrudnicki
            Nov 21 at 9:41










          • @rrudnicki it is your package reason, I can't sure v1.1.10/angular-material.js is ok for angular1.7.5. Please open material.angularjs.org Demo and click the CodePen icon, paste your source there.
            – incNick
            Nov 21 at 11:26


















          • Hi incNick, I added the code in codepen.io, and added the ngMaterial, but for some reason, my code is not showing correct there. Here is what I am seeing: codepen.io/renato-rudnicki/pen/dQJLVZ
            – rrudnicki
            Nov 21 at 9:41










          • @rrudnicki it is your package reason, I can't sure v1.1.10/angular-material.js is ok for angular1.7.5. Please open material.angularjs.org Demo and click the CodePen icon, paste your source there.
            – incNick
            Nov 21 at 11:26
















          Hi incNick, I added the code in codepen.io, and added the ngMaterial, but for some reason, my code is not showing correct there. Here is what I am seeing: codepen.io/renato-rudnicki/pen/dQJLVZ
          – rrudnicki
          Nov 21 at 9:41




          Hi incNick, I added the code in codepen.io, and added the ngMaterial, but for some reason, my code is not showing correct there. Here is what I am seeing: codepen.io/renato-rudnicki/pen/dQJLVZ
          – rrudnicki
          Nov 21 at 9:41












          @rrudnicki it is your package reason, I can't sure v1.1.10/angular-material.js is ok for angular1.7.5. Please open material.angularjs.org Demo and click the CodePen icon, paste your source there.
          – incNick
          Nov 21 at 11:26




          @rrudnicki it is your package reason, I can't sure v1.1.10/angular-material.js is ok for angular1.7.5. Please open material.angularjs.org Demo and click the CodePen icon, paste your source there.
          – incNick
          Nov 21 at 11:26


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404174%2fangularjs-doesnt-work-with-multiple-flag%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Wiesbaden

          Marschland

          Dieringhausen