Seeking guidance on implementing a hierarchical structure in Angular, where a directive (<partition>
) can trigger a method on a child directive's controller (<property-value>
).
Sample example provided:
https://jsfiddle.net/95kjjxkh/1/
The code includes an outer directive, <partition>
, containing one or more <property-value>
directives.
The <property-value>
directive has an editing method, editItem()
, enabling users to modify entries. A random number is assigned in the current example, but typically a modal would prompt for new values in production.
While this setup works well, I aim to allow the outer directive, <partition>
, to create and trigger the editing method of a new <property-value>
directive immediately for user input. If no initial value is entered, the new item should be removed.
I've come across instances of inner directives invoking methods on their enclosing directives, but not vice versa.
Is there a way to achieve this interaction? Alternatively, would you recommend a different approach for constructing this view?