Answer the question
In order to leave comments, you need to log in
Angular: How to dynamically create an htmlelement bound to a js object?
There is a set of lists of the form:
<div>
<ul>
<li>...</li>
<li>...</li>
</ul>
....
<ul>
<li>...</li>
<li>...</li>
</ul>
</div>
product.byId = {23: {name: 'product1'}, 45: {name: 'product2'} }.
Answer the question
In order to leave comments, you need to log in
here is what I wanted to do:
var el = angular.element(ulHtmlEl);
$scope.$apply(function() {
var scope = $scope.$new(); // создаём дочерний scope
scope.prod = $scope.product.byId[productData.id];
el.append($compile(
'<li>{{prod.fullDescr}}</li>'
)(scope));
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question