How to add Angular-enabled elements to DOM?

后端 未结 3 755
谎友^
谎友^ 2021-02-06 02:26

I would like to add some Angular-enabled DOM elements programmatically. Actually, I probably will need to add custom components. How can I do it?

Here\'s a trivial fiddl

3条回答
  •  梦毁少年i
    2021-02-06 02:46

    If you want multiple tests, I'd suggest setting it up like so.

    {{test.name}}
    $scope.tests = []; // define this as an array $scope.add = function() { var newTest = {name: 'Test Message'}; $scope.tests.push(newTest); };

    This will dynamically create divs based on your tests object.

提交回复
热议问题