xebia/ngTagsInput

Name: ngTagsInput

Owner: Xebia BV

Description: Tags input directive for AngularJS

Created: 2016-10-20 09:07:33.0

Updated: 2016-10-20 09:07:34.0

Pushed: 2017-05-23 09:49:03.0

Homepage: http://mbenford.github.io/ngTagsInput

Size: 3087

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

ngTagsInput

Travis Coveralls David GitHub release

Tags input directive for AngularJS. Check out the ngTagsInput website for more information.

Requirements
Installing

All files are available from a variety of sources. Choose the one that best fits your needs:

You can also grab the latest build generated by Travis. It's fully functional and may contain new features and bugfixes not yet published to the services listed above.

Now all you have to do is add the scripts to your application. Just make sure the ng-tags-input.js file is inserted after the angular.js script:

ipt src="angular.js"></script>
ipt src="ng-tags-input.js"></script>
k rel="stylesheet" type="text/css" href="ng-tags-input.css">
Usage
  1. Add the ngTagsInput module as a dependency in your AngularJS app;
  2. Add the custom element <tags-input> to the HTML file where you want to use an input tag control and bind it to a property of your model. That property, if it exists, must be an array of objects and each object must have a property named text containing the tag text;
  3. Set up the options that make sense to your application;
  4. Enable autocomplete, if you want to use it, by adding the directive <auto-complete> inside the <tags-input> tag, and bind it to a function of your model. That function must return either an array of objects or a promise that eventually resolves to an array of objects (same rule from step 2 applies here);
  5. Customize the CSS classes, if you want to.
  6. You're done!

Note: There's a more detailed getting started guide on the ngTagsInput website.

Example
l>
d>
<script src="angular.min.js"></script>
<script src="ng-tags-input.min.js"></script>
<link rel="stylesheet" type="text/css" href="ng-tags-input.min.css">
<script>
    angular.module('myApp', ['ngTagsInput'])
        .controller('MyCtrl', function($scope, $http) {
            $scope.tags = [
                { text: 'just' },
                { text: 'some' },
                { text: 'cool' },
                { text: 'tags' }
            ];
            $scope.loadTags = function(query) {
                 return $http.get('/tags?query=' + query);
            };
        });
</script>
ad>
y ng-app="myApp" ng-controller="MyCtrl">
<tags-input ng-model="tags">
    <auto-complete source="loadTags($query)"></auto-complete>
</tags-input>
dy>
ml>
Options

Check out the documentation page for a detailed view of all available options.

Demo

You can see the directive in action in the demo page.

Contributing

Before posting an issue or sending a pull request, make sure to read the CONTRIBUTING file.

License

See the LICENSE file.

Changelog

See the CHANGELOG page.

Alternatives

The following are some alternatives to ngTagsInput you may want to check out:

Latest build

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.