Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将值传递给typescript中的href标记_Typescript_Ionic Framework - Fatal编程技术网

将值传递给typescript中的href标记

将值传递给typescript中的href标记,typescript,ionic-framework,Typescript,Ionic Framework,如何从我的输入字段将值设置为href标记。当用户单击href标签的值时,该标签为=“skype:+(输入值)?应调用 <ion-content padding> <ion-col> <ion-label color="primary">Enter The No.</ion-label> <ion-input placeholder="Text Input"></ion-input>

如何从我的输入字段将值设置为href标记。当用户单击href标签的值时,该标签为=“skype:+(输入值)?应调用

<ion-content padding>
    <ion-col>
         <ion-label color="primary">Enter The No.</ion-label>
    <ion-input placeholder="Text Input"></ion-input>
      <a href="skype:+jelordrey?call">
    <button  ion-button color="secondary">test</button>
     </a>
       <!--  <a href="skype:+jelordrey?call">
               <button >
                        Click to open Skype and dial the no:+1234567890
              </button>
      </a> -->
 </ion-col>

</ion-content>
export class SkypecallPage {

  constructor(public navCtrl: NavController, public navParams: NavParams) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad SkypecallPage');
  }

}

输入编号。
导出类SkypecallPage{
构造函数(公共navCtrl:NavController,公共navParams:navParams){
}
ionViewDidLoad(){
log('ionViewDidLoad SkypecallPage');
}
}

您可以使用[attr.href]选项动态设置href值。代码如下所示

<a [attr.href]="'skype:+' + name + '?call'">
 <button ion-button color="secondary">test</button>
</a>


如果angluar在执行上述操作时通过在href中前缀unsafe:string将其检测为不安全url,则可能必须使用dom sanitizer将其设置为安全url。您可以检查如何使用dom sanitizer,您可以使用[attr.href]选项动态设置href值。代码如下所示

<a [attr.href]="'skype:+' + name + '?call'">
 <button ion-button color="secondary">test</button>
</a>


如果angluar在执行上述操作时通过在href中加前缀unsafe:string将其检测为不安全url,则您可能必须使用dom sanitizer将其设置为安全url。您可以查看如何使用dom sanitizer。您正在使用输入从用户获取数据。因此,您必须首先在该ion输入上使用ngModel,以便可以绑定模型名称到您的href属性:

因此,请在html中使用以下内容:

<ion-item>
   <ion-label color="primary">Enter The No.</ion-label>
  <ion-input type="text" placeholder="Enter Your Number" [(ngModel)]="userNumber"></ion-input>  //you can use any model name and declare it in your ts
</ion-item>

输入编号。
//您可以使用任何模型名称并在ts中声明它
然后使用[attr.href]将该ngModel值绑定到href属性中:

<a>[attr.href]="'skype:+' + userNumber + '?call'"</a>

正如SAJ提到的,检查如何处理不安全的url

您正在使用输入从用户获取数据。因此,您必须首先在该ion输入上使用ngModel,以便将模型名称绑定到href属性:

因此,请在html中使用以下内容:

<ion-item>
   <ion-label color="primary">Enter The No.</ion-label>
  <ion-input type="text" placeholder="Enter Your Number" [(ngModel)]="userNumber"></ion-input>  //you can use any model name and declare it in your ts
</ion-item>

输入编号。
//您可以使用任何模型名称并在ts中声明它
然后使用[attr.href]将该ngModel值绑定到href属性中:

<a>[attr.href]="'skype:+' + userNumber + '?call'"</a>
正如SAJ提到的,检查如何处理不安全的url