Reputation: 199
I am working on an angular directive and i am trying to prepend an element.
.directive('someDirective', function($compile){
restrict: "E",
scope:{
items="@"
}
link: function(scope,elem,attrs){
// selector
angular.element(div > ul).prepend($compile('<p> Hello World <p>') (scope))
},
template:`
<div class="container">
<ul class="foo">
<li ng-repeat="item in items"> {{ item }} </li>
</ul>
</div>`
});
it appends inside ul. How am i supposed to append the element after the ul tag?
<div class="container">
<ul class="foo">
<!-- prepend element goes here :( -->
<li ng-repeat="item in items"> {{ item }} </li>
</ul>
<!-- I want the prepended element to go here -->
</div>`
i believe there is something wrong with my selector.
Upvotes: 1
Views: 20