【问题标题】:Can't get AngularJS decorator for TextAngular to work无法让 TextAngular 工作的 AngularJS 装饰器
【发布时间】:2014-12-16 13:04:45
【问题描述】:

我不确定我是否完全理解 AngularJS 中的 装饰器 - 我正在尝试修改 TextAngular,如下例所示:https://github.com/fraywing/textAngular/wiki/Setting-Defaults

我的代码:

angular.module('MyAngularApp', ['cfp.hotkeys', 'omr.angularFileDnD', 'textAngular']);

angular.module('MyAngularApp', ['textAngular']).config(['$provide', function ($provide) {
    // changing the classes of the icons
    $provide.decorator('taTools', ['$delegate', function (taTools) {
        taTools.bold.iconclass = 'icon icon-button';
        return taTools;
    }]);
}]);

激活此装饰器后,我只得到一个空白网页,没有错误消息。

有什么想法吗?

【问题讨论】:

  • 首先,要检索现有的角度模块,您只需为其命名,而不是数组的第二个参数。
  • 哎哟!感谢您指出。问题解决了。

标签: angularjs decorator


【解决方案1】:

@JoelJeske 评论是正确的 - 只需获取您的模块,不要重新声明它。

angular.module('MyAngularApp', ['cfp.hotkeys', 'omr.angularFileDnD', 'textAngular']);

angular.module('MyAngularApp').config(['$provide', function ($provide) {
    // changing the classes of the icons
    $provide.decorator('taTools', ['$delegate', function (taTools) {
        taTools.bold.iconclass = 'icon icon-button';
        return taTools;
    }]);
}]);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-20
    • 2011-11-22
    • 2021-05-29
    • 1970-01-01
    • 2012-04-15
    • 2019-05-17
    • 2021-01-06
    相关资源
    最近更新 更多