Javascript 找不到名称';安全网址';

Javascript 找不到名称';安全网址';,javascript,html,angular,ionic2,Javascript,Html,Angular,Ionic2,我正在尝试从我添加的控制台中删除不安全警告bypassSecurityTrustUrl方法。但是我得到了错误 user.component.ts import {Component,OnInit} from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { NavParams,Platform,ViewController } from 'ionic-angular'; @Co

我正在尝试从我添加的控制台中删除不安全警告bypassSecurityTrustUrl方法。但是我得到了错误

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);
    }

}
从'@angular/core'导入{Component,OnInit};
从“@angular/platform browser”导入{domsanizer};
从“ionic angular”导入{NavParams,Platform,ViewController};
@组成部分({
templateUrl:``,
风格:[`
.anchor黑色{颜色:#000;字体大小:2.4rem;}
.anchor默认值{文本装饰:无;}
.自定义边距{左边距:10px;}
.anchor right{float:right;padding top:2px;}
.text内容{文本溢出:省略号;垂直对齐:中间;填充顶部:12px;}
`]
})
导出类用户实现OnInit{
公共用户;
公共bStandings:布尔值=false;
建造师(
公共导航参数:导航参数,
公共视图Ctrl:ViewController,
公共平台:平台,
公共domsanizer:domsanizer
) {}
清理(url:string){
返回此.sanitizeUrl(url);
}
私有sanitizeUrl(url:string):安全url{
this.bStandings=true;
返回此.domsanizer.bypassSecurityTrustUrl(url);
}
}
相关问题:


任何人请帮助我,提前谢谢

也只需导入
SafeUrl

import { DomSanitizer, SafeUrl } from '@angular/platform-browser';

也只需导入
SafeUrl

import { DomSanitizer, SafeUrl } from '@angular/platform-browser';

为什么需要清理
user.mobile\u no
?为什么需要清理
user.mobile\u no