ionic获取表单input的值的两种方法
1.参数传递法
直接在input处使用 #定义参数的name值,注意在ts中参数的类型
html页面:
<ion-input type="text" placeholder="请输入账号" #username></ion-input>
<ion-input type="password" placeholder="请输入密码" #password></ion-input>
<button (click)="login(username, password)">登录</button>
ts文件中(HTMLInputElement类型)
login(username: HTMLInputElement, password: HTMLInputElement) {
console.log(username.value)
console.log(password.value)
}
2.双向数据绑定
html页面:
<ion-input type="text" placeholder="请输入账号" [(ngModel)]="username"></ion-input>
<ion-input type="password" placeholder="请输入密码" [(ngModel)]="password"></ion-input>
<button (click)="login()">登录</button>
ts文件中:
username: string;
password: string;
login() {
console.log(this.username);
console.log(this.password);
}
ionic获取表单input的值的两种方法的更多相关文章
- PHP获取MySql新增记录ID值的3种方法
From: http://www.jb51.net/article/51473.htm 这篇文章主要介绍了PHP获取MySql新增记录ID值的3种方法,一般使用PHP自带函数mysql_insert_ ...
- 选中没有选中的复选框,匹配含有某个字符串的正则,json取值的两种方法,把变量定义在外面跟里面的区别
一.筛选没有选中的复选框:not("input:checked") 二.匹配有VARCHAR的字符串:".*VARCHAR.*?" 三.json取值的两种方法 ...
- javascript获取json对象的key名称的两种方法
javascript获取json对象的key名称的两种方法 数据处理中,你可能接收到一个不确定内容格式的json对象,然后要把key的值提取出来.今天试过两种可以提取json key的方法,均可以正常 ...
- JMeter接口测试-提取动态列表最后一个值的两种方法
前言 在用JMeter做接口测试时,我们经常会遇到,一个接口返回一个json串,在这个json串中,某个节点的值是一个列表,而且这个列表的长度是动态变化的.今天我们来学习两种提取动态列表最后一个值的两 ...
- javascript获取表单的各项值
何谓表单? 表单是html页面中负责数据采集功能的部件,它往往由三个部分组成: 表单标签:<form></form> 用于声明表单的范围,位于表单标签中的元素将被提交.属性有m ...
- Java代码中获取配置文件(config.properties)中内容的两种方法
方法千千万,本人暂时只总结了两种方法. (1)config.properties中的内容如图 在applicationContext.xml中配置 <!-- 引入配置文件 --> < ...
- js jquery, jquery-ui 获取form各种表单input的值?
如何获取? make up (for): 弥补, 补偿, her beaty cannot make up for her stu'pidity. five Basic laws of human s ...
- 表单input中录入资料的检查方法及示例
本文内容 表单录入信息的检查原则 常见检查的三种方法 示例 输入框有字符长度的限制 输入框有输入字符个数范围的限制 知识补给--检查方式的介绍 输入框只可(或不可)输入数 ...
- Selenium获取input值的两种方法:WebElement.getAttribute("value")和WebElement.getText()
在页面元素的定位中,有时候需要获取到元素的页面显示值,用来作为断言.例如,我需要获取email的值"amy1111@xxx.com". <input class=" ...
随机推荐
- 阿里云对象存储 OSS 应用服务器搭建代码
背景说明 最近做一个APP客户端图片直传阿里云OSS的服务,需要在后台开一个阿里云的OSSToken获取的接口. 阿里云官方文档地址:快速搭建移动应用直传服务. 略过移动端说明,直接看服务端的. 不是 ...
- [Swift]LeetCode148. 排序链表 | Sort List
Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2-> ...
- [Swift]LeetCode219. 存在重复元素 II | Contains Duplicate II
Given an array of integers and an integer k, find out whether there are two distinct indices i and j ...
- [Swift]LeetCode457. 环形数组循环 | Circular Array Loop
You are given an array of positive and negative integers. If a number n at an index is positive, the ...
- [Swift]LeetCode546. 移除盒子 | Remove Boxes
Given several boxes with different colors represented by different positive numbers. You may experie ...
- [Swift]LeetCode567. 字符串的排列 | Permutation in String
Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. I ...
- [Swift]LeetCode930. 和相同的二元子数组 | Binary Subarrays With Sum
In an array A of 0s and 1s, how many non-empty subarrays have sum S? Example 1: Input: A = [1,0,1,0, ...
- Linux查看系统、核数、CPU、位数
查看系统: cat /etc/os-release 结果为 centOS Linux 7 查看核数和CPU: lscpu 40 个核,处理器为 Intel(R) Xeon(R) CPU E7-8891 ...
- NDK开发入门终极教程
0 前言 同NDK技术的渊源始于3年前,使用so文件的时候了解到NDK技术,并且C语言一直是强项,就鼓捣起NDK开发.在AndroidStduio还没推广的年代,基于eclipse搭建NDK开发环境需 ...
- sequelize问题集锦
查询: 查询在指定时间范围内的所有数据 options.where.crawl_time = { $lt: new Date('2017-04-08 00:00:00'), $gt: new Date ...