AngularJS带有HTML样式的内容显示的方法

就是随手记在这,没有特别深入的Angular学习经验,所以反正我是这么解决的。

farriorModule.directive('stringHtml' , function(){
  return function(scope , el , attr){
    if(attr.stringHtml){
      scope.$watch(attr.stringHtml , function(html){
        el.html(html || '');//更新html内容
      });
    }
  };
});

 调用的时候就这么写就行啦

<p string-html="content"></p>

 

posted @ 2015-12-10 13:41  DeanChiong  阅读(1090)  评论(0编辑  收藏  举报