简体   繁体   English

将角材料中的多个选定项彼此堆叠?

[英]Stack on top of the each other the multiple selected items in Angular-Material?

Here is a Codepen for the behavior that I have. 这是我的行为的Codepen

The multiple selected options are being stack one next to the other, but the problem with this is once the user select more and more options the options text overflow the text box of a form with a set width. 多个选择的选项一个接一个地堆叠,但是问题是,一旦用户选择了越来越多的选项,选项文本就会溢出具有设定宽度的表单文本框。

I need to find a way to stack the selected options on top of each other once the end of the text box is reach therefor keep all the options stack with in the form box. 我需要找到一种方法,一旦到达文本框的末端,就可以将所选选项彼此堆叠在一起,从而将所有选项堆叠在一起。

 (function () { 'use strict'; angular .module('MyApp') .controller('AppCtrl', function($scope) { this.likedAnimals = ["mouse", "dog"]; this.animals = ["mouse", "dog", "cat", "bird", "LongAnnnnnnimal","LongerrrrrrrrrrrrText"]; }); })(); 
 <div> <md-input-container> <md-select multiple ng-model="ctrl.likedAnimals" placeholder="please select"> <md-option ng-repeat="a in ctrl.animals" value="{{a}}">{{a}}</md-option> </md-select> </md-input-container> </div> 

I think you should specify width in px to set the the exact width of md-select rather than specifying width to md-option . 我认为您应该以px为单位指定width ,以设置md-select的确切宽度,而不是将width指定为md-option See the below link. 请参阅下面的链接。

http://codepen.io/next1/pen/xVLEpy http://codepen.io/next1/pen/xVLEpy

<md-input-container style="background-color:cyan">
<md-select flex style="background-color:yellow;width:200px" multiple ng-model="ctrl.likedAnimals" placeholder="please select"  >
  <md-option ng-repeat="a in ctrl.animals" value="{{a}}">{{a}}</md-option>
</md-select>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM