如何在AngularJS中两个几乎相同的指令之间仅返回一个指令?

问题描述 投票:0回答:1

我如何在两个相同的指令中仅包含一个指令,而其中一个已弃用功能,而另一个不被弃用?

  1. 已弃用的文件无法删除(文件已删除)。
  2. 我记得有一种方法可以获取所有同名的指令并返回它们的数组,让我选择应返回的指令,但我现在找不到了。
var app = angular.module('myModule');

app.directive('myDirective1',
// returns all the needed things;
);

app.directive('myDirective1',
// returns all the needed things, plus some additional stuff;
);

如何仅返回/注册第一个myDirective1而没有第二个?

angularjs angularjs-directive angularjs-decorator
1个回答
0
投票

找到方法

.config(['$provide', function ($provide) {
    // Returns the second registered uiGridOdataDirective from module,
    // so we dont call the same functionality twice.
    $provide.decorator('uiGridOdataDirective', ['$delegate', function ($delegate) {
        return [ $delegate[1] ];
    }]);
}]);
© www.soinside.com 2019 - 2024. All rights reserved.