Ionic Popover模板URL和angular ng模型没有't同步
Ionic Popover templateURL and angular ng-model doesn't sync
我使用的是Ionic框架,我有以下代码:
$scope.loginCountryCode;
$scope.loginPhone;
//==============================//
$ionicBackdrop.retain();
$ionicPopup.show({
title : 'Please Login',
subTitle : 'Please enter the following details',
templateUrl : 'loginTemplate.html',
scope : $scope,
buttons : [{
text: '<b>Send SMS Code</b>',
type: 'button-positive',
onTap: function(e)
{
$scope.buttonToSend = e;
if(!$scope.sendSMS())
e.preventDefault();
else
$scope.userDataForm = true;
}
}]
});
//==============================//
$scope.sendSMS = function()
{
if(!$scope.loginCountryCode || $scope.loginCountryCode ==""){
$scope.loginCountryCodeEmpty = true;
return false;
}
if(!$scope.loginPhone || $scope.loginPhone ==""){
$scope.loginPhoneEmpty = true;
return false;
}
}
<div class="container">
<label class="item item-input">
<div class="input-label" style="float:left;width:55%">
Country Code
</div>
<input type="tel" placeholder="123..." ng-model="loginCountryCode">
</label>
<label class="item item-input">
<div class="input-label" style="float:left;width:50%">
Phone Number
</div>
<input type="text" placeholder="123...." ng-model="loginPhone">
</label>
</div>
$scope.loginCountryCode
未定义,$scope.loginPhone
也未定义,即使使用ng-model="loginCountryCode"
和ng-model="loginPhone"
奇怪的是,如果我声明$scope.loginCountryCode = 123;
,那么ng模型值是123,但它无法识别输入中的变化。有什么想法吗?谢谢:)
如果没有登录模板的一些代码,我很难在脑海中做到这一点,所以我只是在这里根据Ionic 的夜间构建构建了一个快速的codePen
http://codepen.io/aaronksaunders/pen/ogdzNE
angular.module('mySuperApp', ['ionic'])
.controller('PopupCtrl',function($scope, $ionicPopup, $timeout) {
// Triggered on a button click, or some other target
$scope.showPopup = function() {
$scope.loginData = {};
// An elaborate, custom popup
var myPopup = $ionicPopup.show({
templateUrl: 'popup-template.html',
title: 'Enter Wi-Fi Password',
subTitle: 'Please use normal things',
scope: $scope,
buttons: [
{ text: 'Cancel' },
{
text: '<b>Save</b>',
type: 'button-positive',
onTap: function(e) {
alert(JSON.stringify($scope.loginData));
}
},
]
});
};
});
相关文章:
- Ionic Popover模板URL和angular ng模型没有't同步
- 模型绑定在 AngularJS 中不同步
- 骨干.js 3路模型同步
- 如何将前端模型与后端数据库同步
- 在模型同步时发送带有 json 的 API 密钥
- BackboneFire 是否支持使用自动同步模型的非自动同步收集?
- 在应用程序级别替换主干同步 - 而不是通过模型或 Xollection
- Backbone.js模型和集合同步
- 在sharepoint javascript模型的每个循环中同步执行QueryAsync
- Angular: checkbox group'的验证与模型不同步
- 如何在一个backbone.js模型同步中合并多个json请求
- 同步我的knockoutjs模型与我的后端(PHP)
- 如何跟踪未同步到服务器的模型更改?
- EmberJS -保持模型与本地存储中的数据同步
- 使用backbonejs和jquery将模型同步到asp.net服务器
- 在AngularJS中,模型和视图在回调后不同步,并且$apply给出错误
- 如何构建嵌套的backbone.js模型,这些模型可以被不同的底层同步方法重用
- 主干:同步模型和LocalStorage
- Vue.js |手动触发事件破坏模型同步
- Backbone.js序列化模型属性以进行同步