Angularjs single-Selection to multi-select development process

Source: Internet
Author: User

Very simple requirements: before the drop-down box is a radio, now want to change to multiple selection.

Development process:

question one: The first thing I think of is to find a example on the Internet, found that it seems angularjs have the corresponding JS package to achieve, the most of which is isteven-multi-select angularjs-dropdown-multiselect ET.

I downloaded it, but it was ugly when I set it inside my project. And it seems that these JS packet coupling is very high, not I want the kind, so still intend to use simple md-select, md-option, Md-checkbox

To achieve the effect I want, and do not want to write too manual, so check angularjs some of the controls demo, and finally found what I want.

Https://material.angularjs.org/1.1.3/demo/select

So I began to set up the project, but how to set, are not out of the demo on the style, multi-choice is able to choose more, but there is no such as a checkbox of the square box, all kinds of Baidu Google, is not know what the reason. Originally intended to give up, but such a good demo, so Easy JS, don't bear to give up Ah, say give up also can not find other more suitable and not show abrupt style. So resistant to the heart to go over and over to see setting, all is not a problem, in addition to the version inconsistent. Don't? My sixth sense tells me that maybe it's a version of the reason. Previously used version is "angular-material": "1.0.0-rc2", use the latest version of "Angular-material": "1.1.3", so, the effect came out, really is the version reason, I silently in the bathroom to cry for a while.

Problem two: The style of the problem solved, not far from the success. Want to make a multi-choice effect, because there are many options, there is no more choice is really bad experience. So you use one of the options to do a full selection, but do not know what the option has an event, can not find the corresponding property description document, there is only one checked property, but in JS do not know how to judge checked or no checked, and finally gave up, The top made a button to fix it.

Question three: Another problem, is to update the "angular-material": "1.1.3" version, it seems Md-input-container label length is too long, it shows 3Dot (...) , and before it can be displayed in a newline, the experience is not as good as the previous version. Google on the internet for a long time did not Google out of the benefits of such a correction, so decisively customize the CSS, change back to the original style.

Part of the code involved:

Html:

<md-input-container flex= "class=" Md-input-has-value "> <label> Product Type &L t;/label> <md-select ng-model= "Params.producttype" md-on-close= "Clearsearchte                                            RM () "Ng-change=" Change (params.producttype) "data-md-container-class=" Selectheader "multiple> <div> <button ng-click= "Ptchecknone ()" Class= "MD                                            -button md-ink-ripple "><i class=" Zmdi zmdi-undo ng-scope "></i> Reset </button>                                                </div> <md-select-header class= "Select-header" > <input ng-model= "searchterm" type= "search" placeholder= "search for a Produc                                   T.: "class=" Header-searchbox md-text "> </md-select-header>         <md-optgroup label= "Producttypes" > <md-option value= "{{it Em.key}} "ng-repeat=" Item in Producttypes |                                        Filter:searchterm ">{{item.value}}</md-option> </md-optgroup> </md-select> </md-input-container>
Js:

$scope. producttypes = [      {"Key": "SecureSiteProEV1", "Value": "Product1"},      {"key": "SecureSiteProEV2", "value" : "Product2"},      {"key": "SecureSiteProEV3", "Value": "Product3"},      {"key": "SecureSiteProEV4", "Value": " Product4 "},      {" key ":" SecureSiteProEV5 "," Value ":" Product5 "}];
Css

Md-input-container label:not (. md-no-float): Not (. md-container-ignore), Md-input-container. Md-placeholder {    White-space:normal;}



Angularjs single-Selection to multi-select development process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.