2017-01-02 1 views
0

문자열을 HTML 코드로 변환하는 데 문제가 있습니다. 그냥 & # 160을 HTML 코드로 변환하고 싶습니다.이 값은 변수 String에서 설정합니다. 이이 값 &#160를 보유하는 문자열 변수입니다,문자열을 각도 2의 HTML 코드로 변환

this.spaceMenu

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>
내 코드

입니다. 전에 삽입하고 싶습니다 <md-checkbox.

누구든지 나를 도울 수 있다면?

답변

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

safeHtml 파이프에 대한 세부 사항은 모든 여부에 여기에 필요한지 여부를 In RC.1 some styles can't be added using binding syntax
확실하지 참조하십시오.

+0

내 코드의 기능은 TreeView, TreeView를 만드는 것입니다. 이제이 코드를 다시 사용하지 않아도됩니다. 회신 해 주셔서 감사합니다. –