indrimuska / angular-selector

A native AngularJS directive that transform a simple <select> box into a full html select with typeahead.
http://indrimuska.github.io/angular-selector
MIT License
96 stars 36 forks source link

Use different class name for nested form fields #14

Closed kmturley closed 8 years ago

kmturley commented 8 years ago

In the 'selector/selector.html' template you are using the .selector class name in several places:

<div class="selector"

and

<input class="selector"

This class should really be the top level class, and the nested items should have a different class. E.g. if I wanted to run angular-selector directive as a class:

this.restrict   = 'C';

And in my html:

    <label for="tags">Tags</label>
    <select id="tags" class="selector" placeholder="Select multiple" model="tags" multi="true">
        <option value="item1">Item 1</option>
        <option value="item2">Item 2</option>
        <option value="item3">Item 3</option>
    </select>

This would't work because selector is now used for the top-level element AND within the 'selector/selector.html' template.

Suggestion is to change the nested fields to use a different class e.g. .selector-item

<div class="selector-item"

and

<input class="selector-item"

and update the css to support this change. Then all plays nicely if you use as class directive!

indrimuska commented 8 years ago

Mmmm.. good point! Angular Selector is not available through directive class restriction "C", but it might be with this simple update. Now, the "selector" class is listed in the root element and in the input field due to my laziness in repeating some css attributes in the stylesheet. :)