-1
我如何在angulrjs的控制器中傳遞html?添加html到帶角js的div
這裏是我的list.html:
<div class="col-xs-3" ng-repeat="item in companyData">
<a ng-click="getPackageInfo({{item.iCompanyID}},'{{item.vCompanyName}}')" class="block panel padder-v bg-primary item">
<span class="text-white block">{{item.vCompanyName}}</span>
</a>
<div id="packagehtml"></div>
</div>
<div id="lp" class="col-md-12 listing-div hidden"></div>
在controller.js:
$scope.pData = [];
$scope.getPackageInfo = function(id,name) {
$scope.name = name;
var summery = SubscriptionoptioncompanylistFactory.getSummary(id);
document.getElementById("lp").classList.remove("hidden");
$('.packages-data').html('');
$('#loading').show();
SubscriptionoptioncompanylistFactory.getPackageInDetail(id).
success(function(data) {
if(data != 0) {
$("#lp").html(summery); // this is used to append the data
document.getElementById("np").classList.add("hidden");
Array.prototype.push.apply($scope.pData, data);
$('#loading').hide();
} else {
document.getElementById("lp").classList.add("hidden");
document.getElementById("np").classList.remove("hidden");
$('#loading').hide();
}
});
};
在這裏,我已經寫了$("#lp").html(summery);
,在該專區我不得不追加HTML中來自var summery = SubscriptionoptioncompanylistFactory.getSummary(id);
。但是這不會附加數據。在控制檯我可以看到數據來自summary
變量。我能怎麼做?
讓我試着拿回 –
它只是打印'{}',沒有別的。不打印'HTML' –
嘗試: ''
代替: ''