2017-04-03 132 views
-2

显示在输入要素多个值我有个像这样的如何使用角度JS

Array[0] 
0 
: 
"January" 
1 
: 
"February" 
2 
: 
"March" 

数组现在我需要显示一个输入元素的数组的所有三个值。 like enter image description here

如何使用角度js来做到这一点。请帮助

这里是你的角度1.X工作尝试UI的选择插件(https://github.com/angular-ui/ui-select/wiki)的HTML

<div class="col-md-4"> 
       <div asterick class="form-group" ng-class="{'form-group has-success': !error['months'] && (submitted), 'form-group has-error': (error['months']) && (submitted)}"> 
        <label for="months">Months</label> 
        <input type="hidden" name="year" ng-model="data.year" value=""> 
        <input type="text" name="months" id="months" ng-model="data.months" class="form-control" ng-required="true"> 
        <span class="er-block" ng-show="monthlyReportFormPage.months.$touched && monthlyReportFormPage.months.$error.required">Please select months.</span> 
        <span ng-show="error.months" class="er-block">{{error.months}}</span> 
       </div> 
      </div> 
+0

显示html模板 –

+1

进行尝试,然后发布代码并提出有关该问题的问题。抱歉,编写你的代码不是我们的任务。 –

+0

可能的重复[如何使用AngularJS在元素中预先选择默认选项](http://stackoverflow.com/questions/41897635/how-to-pre-select-default-options-in- select-multiple-element-using-angularjs) – Und3rTow

回答

0

有很多种选择:

  • 我建议看看Bootstrap Tags Input

    HTML:

    <input type="text" value="html,input,tag" data-role="tagsinput"></input> 
    

    CSS:

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css"> 
    <link rel="stylesheet" href="http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/dist/bootstrap-tagsinput.css"> 
    

    JS:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> 
    <script src="http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js"></script> 
    

    RES ULT:

    enter image description here

  • OR jQuery Tags Input Plugin通过XOXCO:

    enter image description here

  • ,也可以使用纯JavaScript做到这一点。这里是example