使用DomSanitizer改变风格后Ionic 2无法正常工作

时间:2017-11-16 04:20:59

标签: ionic2

我尝试在项目中使用DOM更改样式,但在我的浏览器中没有更改任何内容。当我试图创建控制台时,DOM结构发生了变化。有什么想法吗?

这是我的代码:

HTML:

<div (press)="showBookmarkOption($event)">
  <div *ngFor="let item of isicontent; let i = index" class="content-wrap datanum-{{i}}" #contentwrapper>
    <h3 [innerHTML]="this.sanitizer.bypassSecurityTrustHtml(item.title)"></h3>
    <div [innerHTML]="this.sanitizer.bypassSecurityTrustHtml(item.content)"></div>
  </div>
</div>

TS:

showBookmarkOption(e){

    this.BookmarkTargetDatanum  = e.target.closest('.content-wrap').classList[1].replace('datanum-','');

    let BookmarkTarget:any                  = e.target.closest('div').id;
    if(BookmarkTarget == ''){
        return false;
    }
    let BookmarkMarkdown:any                = document.getElementById(BookmarkTarget);
    let BookmarkMarkdownOffsetTop:any       = BookmarkMarkdown.offsetTop;
    let BookmarkMarkdownOffsetHeight:any    = BookmarkMarkdown.offsetHeight;

    this.bookmarkContent                            = e;
    this.bookmarkContent.target.style.background    = "yellow";

    console.log(e.target);

    actionSheet.present();
}

,结果是

result

0 个答案:

没有答案