Angularjs 如何将文本发送到模态,将模型文本发送到主屏幕?
您能告诉我如何将文本发送到模态视图和模态视图文本发送到主屏幕吗?在我的演示中,我有一个文本字段和按钮。我需要将输入文本发送到modal,在modal上,我有一个文本字段和按钮,我需要在主屏幕上发送输入字段值。如何将主屏幕与模式屏幕进行通信。我需要向modal发送数据,并从modal获取角度数据 这是我的密码:Angularjs 如何将文本发送到模态,将模型文本发送到主屏幕?,angularjs,angularjs-directive,angularjs-scope,ionic-framework,ionic,Angularjs,Angularjs Directive,Angularjs Scope,Ionic Framework,Ionic,您能告诉我如何将文本发送到模态视图和模态视图文本发送到主屏幕吗?在我的演示中,我有一个文本字段和按钮。我需要将输入文本发送到modal,在modal上,我有一个文本字段和按钮,我需要在主屏幕上发送输入字段值。如何将主屏幕与模式屏幕进行通信。我需要向modal发送数据,并从modal获取角度数据 这是我的密码: 您必须声明该范围内的变量,然后绑定它 我已经编辑了你的密码笔 HTML: <html ng-app="ionicApp"> <head> <
您必须声明该范围内的变量,然后绑定它 我已经编辑了你的密码笔 HTML:
<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>Sign-in, Then Tabs Example</title>
<link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
<script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
</head>
<body ng-controller="cntr">
<ion-view>
<ion-header-bar class="bar-balanced">
<h1 class="title">load data before modal show</h1>
</ion-header-bar>
<ion-content scroll="false">
<button ng-click="openmodel()">send data on popup screen </button>
<input type="text" placeholder="Say Something" ng-model="input.saySomething"/>
<h1>{{item.text}}</h1>
</ion-content>
<ion-footer-bar class="bar-balanced">
<h1 class="title">Footer</h1>
</ion-footer-bar>
</ion-view>
<script id="templates/modal.html" type="text/ng-template">
<ion-modal-view>
<ion-header-bar class="bar-balanced">
<h1 class="title">departure</h1>
</ion-header-bar>
<ion-content>
<h1>naveen+{{input.saySomething}}</h1>
<input type="text" ng-model="item.text">
<button>send to main screen</button>
</ion-content>
<ion-footer-bar class="bar-balanced">
<h1 class="title">Footer</h1>
</ion-footer-bar>
</ion-modal-view>
</script>
</body>
</html>
var app =angular.module('ionicApp',['ionic']);
app.controller('cntr',function($scope,$http,$ionicModal){
$scope.item={};
$scope.input={};
$ionicModal.fromTemplateUrl('templates/modal.html', {
scope: $scope
}).then(function(modal) {
$scope.modalFirst = modal;
});
$scope.openmodel=function(){
// alert('d');
$scope.modalFirst.show()
}
})
@f5ed你能解释得更清楚些吗?你对输入的绑定是{{input.saySomething},所以它引用了一个属性saySomething在一个对象输入中,如果在作用域中不可用,ng模型将创建变量/属性,但它不能创建对象及其属性(我想),所以你需要在作用域中为它定义对象
var app =angular.module('ionicApp',['ionic']);
app.controller('cntr',function($scope,$http,$ionicModal){
$scope.item={};
$scope.input={};
$ionicModal.fromTemplateUrl('templates/modal.html', {
scope: $scope
}).then(function(modal) {
$scope.modalFirst = modal;
});
$scope.openmodel=function(){
// alert('d');
$scope.modalFirst.show()
}
})