html不会编译在角度js中追加新的子节点

时间:2016-01-07 05:02:47

标签: javascript angularjs angularjs-compile

我正在尝试动态插入节点,但附加的html没有正确编译。

This is the code on Fiddle

<body ng-app="app">
<div ng-controller="appController"> 
    {{tittle}}
   <div name="name" ng-repeat="d in data" ng-click="click(d.id)" id="div{{d.id}}">{{d.id}} click me</div>
</div>

(function () {
    var app = angular.module('app', []);
    app.controller('appController', function ($scope, $compile) {
        $scope.tittle = "test";
        $scope.data = [{ id: 1, child: [{name:'renjith'}] }, { id: 3 }, { id: 4 }, { id: 5 }, { id: 6 }];
        $scope.click = function (data, $element) {
            debugger;
            var scope = { id: "12" };
          angular.element(document.querySelector("#div" + data)).append($compile("<div ngTransclude>{{d.id}}</div>")($scope.data));
        }
    });
})(); 

0 个答案:

没有答案