Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

How can I display two dropdown menus with the proper options using angular's ng-repeat directive?

Here's a JSBin

js:

 angular.module('myApp', [])
    .controller('MainCtrl', function($scope) {

      $scope.templates = {
        pages: ['home', 'about'],
        posts: ['blog', 'lab']

      };

    });

HTML:

 <div class="container" ng-controller="MainCtrl">
    <form action="" class="col-lg-12" >
       <select class="form-control" ng-repeat="template in templates.pages>
        <option value = "{{ template }}"> {{ template }}</option>
      </select>
      <select class="form-control" ng-repeat="template in templates.posts>
        <option value = "{{ template }}"> {{ template }}</option>
      </select> 
    </form>

  </div>
share|improve this question

1 Answer 1

up vote 0 down vote accepted

ng-repeat should be used in option tags. Also, close double quotes in your ng-repeat expression.

Here your fixed JSBin

share|improve this answer
    
ugh that was a dumb mistakes.. thanks –  Matthew Harwood Jan 9 at 18:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.