AngularJS: reuse component with different parent

前端 未结 1 417
旧时难觅i
旧时难觅i 2021-01-23 00:12

Let\'s say I have A and B reusable components. I want B to invoke a method on A - of course only if B is a child of A. Also - I want B to be used as a standalone component (with

1条回答
  •  无人及你
    2021-01-23 01:03

    You can conditionally require another directive prefixing it with the question mark: require: "^?A". Then you can test for the controller being not-null to see if you were invoked inside a parent directive or as a standalone.

    0 讨论(0)
提交回复
热议问题