plugin-example.js 1.2 KB

123456789101112131415161718192021222324252627282930
  1. var ctx;
  2. module.exports = {
  3. init: function(_ctx) {
  4. console.error("plugin init called, got ctx with keys " + Object.keys(_ctx));
  5. // ctx contains a bunch of helpers and data
  6. // stash it away so you can use it inside match
  7. ctx = _ctx;
  8. // if you want to setup position triggers now, checkout nginject-comments.js
  9. },
  10. match: function(node) {
  11. console.error("plugin match called, node with type " + node.type);
  12. // if you think you have a match, return the found target node
  13. // (may or may not be the passed in argument node)
  14. // you may also return an array of target nodes
  15. // ng-annotate will then execute replaceRemoveOrInsertArrayForTarget
  16. // on every target, i.e. it may remove an array (if --remove) and it may
  17. // add an array (if --add)
  18. // please consider filing an issue if you need to workaround a defect or
  19. // an obviously missing feature in ng-annotate. we'll try to fix it!
  20. // you know about /* @ngInject */, don't you? (you may not need a plugin)
  21. // please consider sending a pull request if your plugin is of general use
  22. },
  23. };