Paul Odeon Paul Odeon - 2 months ago 9
AngularJS Question

Angular directive to match multiple attributes

Can I define an angular directive so that it would match multiple similar terms
i.e.

angular.module('search').directive('platformPreload', function() {
return {
link: function(scope, element, attrs) {
}
}
}


Would match both the following:

<div platform-preload-terms="[]"></div>
<div platform-preload-suggestions="[]"></div>

Answer

There are no wildcard directive declaration.

But you can isolate the function and repeat the definition:

angular.module('search')
    .directive('platformPreload', PlatFunction)
    .directive('platformPreloadSuggestions', PlatFunction)


PlatFunction() {
    return {
        link: function(scope, element, attrs) { }
    }
}