<!DOCTYPE html>
<html ng-app="splessonsApp">
  <head lang="en">
      <meta charset="utf-8">
      <title>SPLessons</title>  
      <link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css">
  </head>
  <body ng-controller="splessonsController">
    
    <div class="container"> 
    
    <div class="jumbotron">
      
    <h3> <a href="http://www.splessons.com/2015/05/angularjs-ng-repeat-filter/" > SPLessons.com </a> </h3>
      
      
    <form class="form-horizontal">
      <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">Control Type: </label>
        <div class="col-sm-10">
          <select name="degree" class="form-control" ng-model="selectedcontroltype" ng-options="filter.value for filter in userfilter track by filter.key" > 
           <option value=""> Select Control Type </option>
          </select>
        </div>
      </div>
    </form>
    
    <p> {{selectedcontroltype.key}}</p>
    
    <table class="table table-bordered">

        <thead>
          <tr>
            <th class="col-md-1"> Sequence</th>
            <th class="col-md-5" > Description </th>
            <th class="col-md-2"> Question Type </th>
            <th class="col-md-2"> Control Type </th>
            <th class="col-md-1"> Status </th>
          </tr>

        </thead>

        <tbody>

        <tr ng-repeat="question_details in list | filter:{controlType:selectedcontroltype.key}:true"  >
            <td class="col-md-1"  > {{$index+1}} </td>
            <td class="col-md-5 text-left" >  {{question_details.description}}</td>
            <td class="col-md-2" >  {{question_details.questionType}}</td>
            <td class="col-md-2" > {{question_details.controlType}}</td>
            <td class="col-md-1" > {{question_details.status}}</td>
        </tr>

        </tbody>

    </table>
    
    
    
   </div>
   
   </div> 
    <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js" type="text/javascript" ></script>
    <script src="app.js" type="text/javascript"></script>
  </body>
</html>
// Code goes here

/* Styles go here */

/**
 * Created by sinukoll on 4/15/15.
 */
'use strict';
var splessonsApp = angular.module('splessonsApp',[]);

splessonsApp.controller("splessonsController",function($scope){
  
  $scope.userfilter = [
                      {"key":"text","value":"Text Box"},
                      {"key":"textarea","value":"Text Area"},
                      {"key":"checkbox","value":"Check Box"}
                   ];
                   
                   
                
  $scope.list = [
                    {"id":1,"description":"What's your first car?","questionType":"Question","controlType":"text","status":"A"},
                    {"id":2,"description":"What is your last friend name?","questionType":"Question","controlType":"text","status":"A"},
                    {"id":3,"description":"Where did you work?","questionType":"Question","controlType":"checkbox","status":"A"},
                    {"id":4,"description":"Do you get enough salary ?","questionType":"Question","controlType":"text","status":"A"},
                    {"id":5,"description":"Last four digits of your phone ?","questionType":"Essay","controlType":"textarea","status":"A"}];
  
  
});