2017-01-02 10 views
0

文字列をHTMLコードに変換する際に問題があります。私は&#160をHTMLコードに変換したいだけです。この値は変数Stringから設定します。これは、それが価値&#160を保持している文字列変数です、私のコード文字列を角2のHTMLコードに変換します

ngOnInit(){ 
 
    this.submitButtonText = 'Save'; 
 
    this.spaceMenu= '   '; 
 
    this.form = this.fb.group({ 
 
     'id': [], 
 
     'name': ['', Validators.compose([Validators.required,Validators.minLength(3)])], 
 
     'description': [] 
 
    }); 
 
    this.name = this.form.controls['name']; 
 
    this.description = this.form.controls['description']; 
 
    this.service.getMenuGroup() 
 
     .subscribe(
 
      data => this.setMenuGroup(data['menuGroup']), 
 
      err => this.logError(err), 
 
      () => this.finishedGetIndexList('Save') 
 
     ); 
 
     this.statusForm = 'Add'; 
 
     if(this.id){ 
 
      this.fetchData(); 
 
     } 
 
    }
<div *ngFor="let item of menuList" [ngClass]="class"> 
 
    <label class="checkbox-inline custom-checkbox nowrap"> 
 
     <md-checkbox 
 
     [name]="checkboxMenu" 
 
     [checked]="(_checkingList(item,selectedMenu))" 
 
     [indeterminate]="(_checkIsIndeterminate(item,selectedMenu))" 
 
              (change)="_onChange(item,$event)" 
 
     [disabled]="true"> 
 
     {{item.name}} 
 
     </md-checkbox> 
 
    </label> 
 
</div>

this.spaceMenuです。私はそれを前に挿入したい<md-checkbox.

誰かが私を助けることができたら? safeHtmlパイプの詳細については

答えて

0
<label ...> 
<span [outerHTML]="spaceMenu | safeHtml"></span> 
<md-checkbox ... 

それはここにすべてではないか、必要かどうかIn RC.1 some styles can't be added using binding syntax
わからない参照してください。

+0

私のコードの機能は、ツリービュー、ツリービューを作成することです、そして今私は、このコードを再度使用しないで、返信のためにしなければならない。 –

関連する問題