[英]Cannot find name 'SafeUrl'
I am trying to remove the unsafe warning from the console I added bypassSecurityTrustUrl method. 我试图从添加了bypassSecurityTrustUrl方法的控制台中删除不安全警告。 But I am getting the error
但是我得到了错误
user.component.ts user.component.ts
import {Component,OnInit} from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { NavParams,Platform,ViewController } from 'ionic-angular';
@Component({
templateUrl:`<a [href]="sanitize('sms:'+user.mobile_no)" class="anchor-default">Text</a>`,
styles:[`
.anchor-black{color: #000; font-size: 2.4rem;}
.anchor-default {text-decoration: none;}
.custom-margin{margin-left:10px;}
.anchor-right{float:right;padding-top:2px;}
.text-content{text-overflow: ellipsis; vertical-align: middle; padding-top:12px;}
`]
})
export class User implements OnInit {
public user;
public bStandings:boolean = false;
constructor(
public navParams:NavParams,
public viewCtrl:ViewController,
public platform:Platform,
public domSanitizer:DomSanitizer
) {}
sanitize(url:string){
return this.sanitizeUrl(url);
}
private sanitizeUrl(url:string):SafeUrl {
this.bStandings = true;
return this.domSanitizer.bypassSecurityTrustUrl(url);
}
}
Related Question: Class has or is using name 'SafeUrl' from external module but cannot be named 相关问题: 类具有或正在使用外部模块中的名称“ SafeUrl”,但无法命名
Anyone please help me thanks in advance 任何人请帮助我提前谢谢
只需导入SafeUrl
:
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.