/atmention

Textarea with @mention autocomplete

Primary LanguageTypeScript

Atmention

CI npm version

Getting started (AngularJS)

Install

npm install --save atmention-angularjs

Import CSS

@import 'node_modules/atmention-angularjs/dist/atmention-angularjs.css'

Add the module to your app

require('angular');
require('atmention-angularjs');

angular.module('app', [
  'atmentionModule'
]);

Component usage

<atmention-textarea
  ng-model="$ctrl.markup"
  placeholder="Use @ to mention someone">
</atmention-textarea>

<button ng-click="$ctrl.save()">Save</button>
function Controller(atmention) {
  $ctrl.markup = 'Nice groove, [Elvin](elvin@example.com)...'

  $ctrl.save = function () {
    var instance = atmention.parse($ctrl.markup);
    instance.getDisplay(); // 'Nice groove, Elvin...'
    instance.getMarkup(); // 'Nice groove, [Elvin](elvin@example.com)...'
    instance.getMentions(); // [{ label: 'Elvin', value: 'elvin@example.com' }]
  };
}