我正在将未经过处理的html注入组件中。当路由参数更改时,我转到数据库并获取一些新的html并将其放入组件中。但是当我这样做时,我收到消息SafeValue must use [property]=binding:
我的猜测是因为路线正在改变而引起的。我的routerlink生成如下:
<li routerLinkActive="active" *ngFor="let form of translationData.caseForms" ><a [routerLink]="[currentTransCode, 'form',form.ClaimTemplateID]" class="navbar-link">{{form.WebsiteLinkTitle}}</a></li>
以下是步骤:
转到http://localhost:4300/us/form/5406 - 没有错误
form.component.html:
<div class="container" *ngIf="!loading">
<div *ngIf="!isAuthenticated">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<strong>Login </strong>
</h3>
</div>
<div class="panel-body">
<div role="form">
<div class="form-group">
<label for="exampleInputEmail1">{{token1Label}}</label>
<input type="email" class="form-control" id="exampleInputEmail1" required placeholder="Enter {{token1Label}}" #token1>
</div>
<div class="form-group">
<label for="exampleInputPassword1">{{token2Label}}
</label>
<input type="password" class="form-control" id="exampleInputPassword1" required placeholder="Enter {{token2Label}}" #token2>
</div>
<button type="button" (click)="login(token1,token2)" class="btn btn-sm btn-primary">Login</button>
</div>
</div>
</div>
</div>
<div *ngIf="isAuthenticated">
<div class="page-header paddingpushdown">
<h2>{{formTitle}}</h2>
</div>
<form [formGroup]="form" (ngSubmit)="submit(model)">
<formly-form [model]="model" [fields]="fields" [options]="options" [form]="form">
<button type="submit" class="btn btn-default">Submit</button>
</formly-form>
</form>
</div>
</div>
包装未经过清理的HTML:
答案 0 :(得分:0)
如果您使用[innerHTML]
绑定,Angular将清理HTML。
<div [innerHTML]="html_goes_here"></div>
我希望这个例子有所帮助。但是,您似乎在问[routerLink]
,所以这不太可能是您正在寻找的。如果没有,您能否提供有关[routerLink]
中传递的参数的更多详细信息?