AngularJS ng-options create range

后端 未结 8 844
鱼传尺愫
鱼传尺愫 2020-11-28 09:58

I am trying to create a select element that has a list of numbers 1 to pages where pages is a variable that is the number of pages I have. What i don\'t know how to do is to

相关标签:
8条回答
  • 2020-11-28 10:28

    If you want to add a placeholder in select, then use below given solution. You need to first define the filter like this.

    <select>
        <option value="">-- Birth Year --</option>
        <option ng-repeat="n in [] | range:1900:2000">{{n}}</option>
    </select>
    
    0 讨论(0)
  • 2020-11-28 10:31

    In CoffeeScript:

    app.filter 'range', ->
      (input, min, max) ->
        input.push(i) for i in [parseInt(min)..parseInt(max)]
    

    And the HTML:

    <select ng-options="n for n in [] | range:1:30"></select>
    

    Here is the gist with the Javascript

    0 讨论(0)
提交回复
热议问题