app.directive( 'addDonation', function ( $compile ) {
return {
restrict: 'E',
scope: {
donors:"="
},
template: '<p class="btn btn-default" ng-click="add()">Add</p>',
controller: function ( $scope, $element ) {
$scope.add = function () {
var el = $compile( '<donation-directive donors="donors"></donation-directive>' )( $scope );
$element.parent().append( el );
};
}
};
});
&#13;
附件是当用户点击按钮时执行的代码说&#34;添加&#34;,在模板附加到视图后整个页面变得更重并开始响应缓慢:(