ionic 完美的融合下一代移动框架,ionic 基于Angular语法,支持 Angularjs 的特性。但是我在开发的时候,遇到了坑。因为之后用的就是angularjs,so 理所当然的以为代码应该时这样的写:

<div class="item item-input">
<span>手 机 号:</span>  
<input type="text" ng-model="phone">
</div> <div class="item item-input">
<span>验 证 码:</span>  
<input type="text" ng-model="code">
<button class="button button-calm" ng-click="ionGetCode()">获取验证码</button>
</div>
<div class="item item-input codeSuccess" >
<span>新 密 码:</span>  
<input type="text" ng-model="newPwd">
</div>
<div class="item item-input codeSuccess" >
<span>确认密码:</span>  
<input type="text" ng-model="confirm">
</div>

  在页面:

{{phone}} //就可以直接获取你输入的值

但是在js中:

 console.log("userName:"+$scope.userName);
console.log("$scope.phone:"+$scope.phone); //无法获取输入的值

之后查了官网文档,也查了很多资料,才知道这样写也不行的,详细解释可以去官网http://ionicframework.com/docs/

<div class="item item-input">
<span>手 机 号:</span>  
<input type="text" ng-model="$parent.phone">
</div> <div class="item item-input">
<span>验 证 码:</span>  
<input type="text" ng-model="$parent.code">
<button class="button button-calm" ng-click="ionGetCode()">获取验证码</button>
</div>
<div class="item item-input codeSuccess" >
<span>新 密 码:</span>  
<input type="text" ng-model="$parent.newPwd">
</div>
<div class="item item-input codeSuccess" >
<span>确认密码:</span>  
<input type="text" ng-model="$parent.confirm">
</div>

  

Ionic之数据绑定ng-model的更多相关文章

  1. Android进阶笔记13:RoboBinding(实现了数据绑定 Presentation Model(MVVM) 模式的Android开源框架)

    1.RoboBinding RoboBinding是一个实现了数据绑定 Presentation Model(MVVM) 模式的Android开源框架.从简单的角度看,他移除了如addXXListen ...

  2. 聊聊 Vue 的双向数据绑定,Model 如何改变 View,View 又是如何改变 Model 的

    todo defineProperty() 参考: https://www.cnblogs.com/wangjiachen666/p/9883916.html

  3. angularJs:双向数据绑定

    示例1 <!DOCTYPE html> <html ng-app> <head> <meta charset="UTF-8" /> ...

  4. 如何实现VM框架中的数据绑定

    作者:佳杰 本文原创,转载请注明作者及出处 如何实现VM框架中的数据绑定 一:数据绑定概述 视图(view)和数据(model)之间的绑定 二:数据绑定目的 不用手动调用方法渲染视图,提高开发效率:统 ...

  5. Vue之双向数据绑定

    demo.html <!DOCTYPE html> <html lang="en" xmlns:v-bind="http://www.w3.org/19 ...

  6. WPF MVVM 之理解(数据绑定)

    (申明:最近在做一个练习,写点东西,谨供参考.) 1.界面展示:其中的布局和样式就不说了,重点在MVVM架构和数据绑定(Model层使用EF(Entity Framework)实体框架,不做介绍). ...

  7. React(6) --双向数据绑定及列表数据循环

    React双向数据绑定:model改变影响view,view改变反过来影响model import React,{Component} from 'react'; class Todolist ext ...

  8. 7_nodejs angularjs

    webstrom使用: ctrl+b/点击,代码导航,自动跳转到定义 ctrl+n跳转指定类 ctrl+d复制当前行ctrl+enter另起一行ctrl+y删除当前行 ctrl+alt/shift+b ...

  9. angular2 学习笔记 ( Component 组件)

    refer : https://angular.cn/docs/ts/latest/guide/template-syntax.html https://angular.cn/docs/ts/late ...

随机推荐

  1. 通过命令打包apk

    平时使用android studio打包,方便快捷,对命令不太熟悉,但在上传apk包到应用市场时,需要认领apk,“认领页的[选择APK]”不是上传您要更新的APK应用文件,而是下载我们提供的空包文件 ...

  2. sql语句,无法绑定由多个部分组成的标识符 "xxx"

    String sql = "select TOP 7 news_id,news_title,news_addtime,news_url from web_news_info a" ...

  3. usaco2008 nov 区间异或求和

    Problem 11: Switching Lights [LongFan, 2008] Farmer John tries to keep the cows sharp by letting the ...

  4. 在Service里调用AlertDialog

    用常规的方法在AlertDialog的时候,会报错,大意是「can not add window in this view」. 原因是Service是没有界面的,只有Activity才能添加界面. 解 ...

  5. 【NOIP2012】 国王游戏

    [题目链接] 点击打开链接 [算法] 按ai * bi升序排序,贪心即可 [代码] #include<bits/stdc++.h> using namespace std; #define ...

  6. 【SDOI2009】SuperGCD

    [题目链接] 点击打开链接 [算法] 1.关于求最大公约数的算法 若使用辗转相除法,那么显然会超时 不妨这样思考 : 要求gcd(a,b), 若a为偶数,b为偶数,则gcd(a,b) = 2 * gc ...

  7. registerWithTouchDispatcher 注册单点触摸事件

    Doc: If isTouchEnabled, this method is called onEnter. Override it to change the way CCLayer receive ...

  8. perceptron and ANN

    %% Perceptron Regression close all clear %%load data x = load('ex4x.dat'); y = load('ex4y.dat'); x=o ...

  9. Collection View Programming Guide for iOS---(七)---Custom Layouts: A Worked Example

    Custom Layouts: A Worked Example Creating a custom collection view layout is simple with straightfor ...

  10. CodeForces 712A Memory and Crow (水题)

    题意:有一个序列,然后对每一个进行ai = bi - bi + 1 + bi + 2 - bi + 3.... 的操作,最后得到了a 序列,给定 a 序列,求原序列. 析:很容易看出来,bi = ai ...