GithubHelp home page GithubHelp logo

pleerock / angular-select-options Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 184 KB

A special angular directive that works like angular's ng-options but can be used in along with any element and has several specific abilities

License: Apache License 2.0

JavaScript 100.00%

angular-select-options's Introduction

select-options directive for AngularJS

This directive allows your inputs to grow as soon as user types. The input's width always fit the text user typed in the input.

Open samples/index.html to see the example how to use this directive.

Installation

  1. Run bower install angular-select-options --save

    • (or add manually into your bower.json dependencies and run bower-install)
    • (or download ZIP from github and extract files in the case if you don't use bower)
  2. Include bower_components/angular-select-options/dist/angular-select-options.js in your index.html file

  3. Add a new dependency in your module

angular.module('yourApp', ['selectOptions', ...])

How to use it

<my-custom-directive ng-model="youCanUseItWithModel" select-options="fruit.name in fruits track by fruit.id"></my-custom-directive>

Then you can get access to your fruits via selectOptions controller in your my-custom-directive directive this way:

angular.module('myModule').directive('myCustomDirective', function () {
   return { // scope type can be any - even isolate
      require: ['ngModel', 'selectOptions'],
      templateUrl: 'select-items.html',
      link: function (scope, element, attrs, controllers) {
      
          var ngModelCtrl        = controllers[0];
          var selectOptionsCtrl  = controllers[1];
         
         // now you can access selectOptionsCtrl to get the data you need (fruits, fruit names, etc.)
         
      }
   }
});

TODO-s (for contributors):

  • refactor some parts of code and make it easier to understand and maintain
  • better documentation and more examples if possible
  • cover sources with unit-tests
  • research in performance optimizations
  • search for bugs and fix them
  • star this project and get people to know about this plugin in angular community

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.