F
F
faragly2015-07-14 17:40:46
Angular
faragly, 2015-07-14 17:40:46

How to insert template directive AFTER element without replacing it in AngularJS?

Good day! The task is to create a pop-up dropdown below the input field, I put my-directive on the input, but here's what to write in the code for the directive so that the element is not replaced (replace: false inserts the directive template into the input, which is also meaningless). I also don't want to place the directive below the text field, then the link between the directive and the field will be lost. The option to move the input inside the template and make a replacement is also not the best, because if the user wants to set some styles, attributes, then they must be in the template that will replace the original input. What are the options for solving this problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
_
_ _, 2015-07-14
@faragly

Not the most elegant solution, but at the pre-link stage of the directive, you can manually append after input and compile.
Here's an example: codepen.io/AMar4enko/pen/QbxqVY

M
Mikhail Osher, 2015-07-14
@miraage

Actually, the dropdown should be inserted at the end of the <body> and be fixed, with an offset top/left.

D
DigitalSmile, 2015-07-14
@DigitalSmile

Make two directives - one will add dropdown, the second implements the widget itself. Connect them with this .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question