我想创建动态html内容,以便从控制器中将数据显示到视图中我尝试使用以下代码来显示数据但是用新数据替换旧数据
data.table
答案 0 :(得分:0)
以这种方式创建div更容易:
<div ng-repeat="post in arrayPost">
<div ng-class="'notifier notice'+ post.checklen"
id="{{post.postreplyid}}" ng-style="margin-top:'+post.toppos">
<div class="replyhere">
<div class="col-sm-11 no-padding">{{post.datas.reply}} </div>
<div class="col-sm-1 no-padding"><a ng-click="gotothisdis({{post.postid}},{{post.postreplyid}})"><img src="images/discussicons/plugsb.png" class="newiconssmalls" /></a></div>
<div class="clearfix"></div>
</div>
<div class="margin6"></div>
<div class="timeago">
<div class="col-sm-11 no-padding">{{post.datas.timing}} ago</div>
<div class="col-sm-1 no-padding"><a ng-click="removethisnot({{post.postreplyid}})"><img src="images/discussicons/wrongb.png" class="newiconssmalls" /></a></div>
<div class="clearfix"></div>
</div>
</div>
在您的控制器中执行此操作:
var checklen = Math.random();
$scope.arrayPost = []
$http.post("getnotifierdis",{"postid":postid,"postreplyid":postrplyid}).then(function(result)
{
var newPost = {}
newPost.datas = result;
newPost.checklen = your value;
newPost.postreplyid = your id;
newPost.toppos = your value;
arrayPost.push(newPost)
.....
});