Alexey Aristov2016-09-20 18:56:15
Alexey Aristov, 2016-09-20 18:56:15

Angular: How to dynamically create an htmlelement bound to a js object?

There is a set of lists of the form:


A new li element can be added to any of the ul lists.
There is a js directory with data of the form:
product.byId = {23: {name: 'product1'}, 45: {name: 'product2'} }.

I want to add li using angular so that it is tied to one of the product.byId. Is it possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Alexey Aristov, 2016-09-21

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];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question