npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-atp

v0.0.2

Published

Angular Autocompleter based on Twitter Bloodhound

Downloads

2

Readme

ngAtp : Angular Autocompleter

Demo

http://yiransheng.github.io/ngAtp/

Credits

The backbone of ngAtp is ngBloodhound, which is almost entirely adopted from twhitbeck's angular-bloodhound, an Angular port of Twitter's Bloodhound.

Quick Start

Include dist/js/ng-atp-bundle.js or dist/js/ng-atp-bundle.min.js on your page (or use as a bower component: bower install ng-atp).

<div ng-atp="city" ng-atp-config="cityAutocompleteOpts">
    <input ng-atp-input />
    <ul ng-atp-suggestions>
    </ul>
</div>

Set ng-atp attribute value to the variable in scope you'd like to autocomplete for, same way you'd use a ngModel directive. Pass Bloodhound config object using ng-atp-config attribute. Additonal config options: idAttribute, specify the key/id attribute to use for tracking suggestion items (similar to track by for ng-repeat). Also, you should to supply two functions in config: format and verify(optional). format is expected to be a function that takes a suggestion datum (eg. { label: "Thing", id: 1}) into a string to display, and verify is expected to be a function that takes a single suggestion datum as an argument, and returns a boolean (be sure to return false for null).

In addition, ng-atp-suggestions allows you to use custom template by suppling an attribute templateUrl. templateUrl should point to a valid Angular template for a single suggestion item (which will be wrapped inside a <li> tag), and ng-atp-suggestions expose the scope variable suggestion for your template, as well as setting the class of the corresponding item to "selected" from user interactions (hover, and arrow key press). An example template may look like this:

<ul ng-atp-suggestions templateUrl="partials/mytemplate.html">
mytemplate.html:

<div>
  <i class="fa {{ suggestion.icon }}"></i>
  <span>{{ suggestion.label }}</span>
  <img src="{{ suggestion.url }}">
</div>

Details

ngAtp implements Twitter Bloodhound as a Angular service, ngBloodhound uses Angular's $http service as opposed to jQuery $.ajax in the original version (inspired by twhitbeck/angular-bloodhound). Other than that, suggestions are entirely managed by Bloodhound with all its prefetching, intelligent caching, fast lookups, and backfilling. On the rendering/directive side of things, ngAtp relies on ng-model and ng-repeat (without filtering, which is handled by Bloodhound), and tries to stick to default Angular directives as much as possilbe.

Dependencies

Angular, Lodash