Controller Required By Directive Can't Be Found

前端 未结 2 1403
慢半拍i
慢半拍i 2020-12-17 08:50

I have a directive that I\'d like another directive to be able to call in to. I have been trying to use directive controllers to try to achieve this.

Directive one

2条回答
  •  清歌不尽
    2020-12-17 09:23

    There is no real way with require to communicate between sibling elements in the way you are trying to do here. The require works the way you have set up if the two directives are on the same element.

    You can't do this however because both of your directives have an associated templateUrl that you want to use, and you can only have one per element.

    You could structure your html slightly differently to allow this to work though. You basically need to put one directive inside the other (transcluded) and use require: '^videoClipDetails'. Meaning that it will look to the parent to find it. I've set up a fiddle to demonstrate this: http://jsfiddle.net/WwCvQ/1/

    This is the code that makes the parent thing work:

    // In videoClipDetails
    template: '
    clip details
    ', transclude: 'true', ... // in markup
    // in fileLibrary require: '^videoClipDetails',

    let me know if you have any questions!

提交回复
热议问题