angular-weibo-emotify

0.3.0 • Public • Published

angular-weibo-emotify

Angular directive and service to emotify weibo text.

Install

bower install angular-weibo-emotify
npm install angular-weibo-emotify

Usage

Inject module and set Emotions (Download) URL

angular.module('YourApp', ['weibo-emotify'])
.config(['weiboEmotifyProvider', function (weiboEmotifyProvider){
    weiboEmotifyProvider.setEmotionsURL('https://example.com/emotions_v2.min.json')
}])

Use as Directive

<!-- As a directive -->
<div weibo-emotify>{{ weibo_text }}</div>

Inject as Service

// Injected into controller
angular.module('someModule').controller('SomeCtrl', function ($scope, weiboEmotify, $sce) {
    var text = "GitHub 年会 2015 [照相机][围观],图里的是 CEO。";
  
    weiboEmotify.then(function (emotify){
        $scope.text = $sce.trustAsHtml(emotify(text));
        // outputs: GitHub 年会 2015 <img text="[照相机]" alt="[照相机]" src="http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/33/camera_org.gif"><img text="[围观]" alt="[围观]" src="http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/f2/wg_org.gif">,图里的是 CEO。
    })
 
});
 

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i angular-weibo-emotify

Weekly Downloads

4

Version

0.3.0

License

MIT

Last publish

Collaborators

  • robermac