Could you please tell me how to send the text to modal view and model view text to main screen? In my demo I have one text field and button. I need to send input text to modal and on modal I have one textfield and button I need to send that input field value on main screen. How we comunicate the main screen to modal screen. I need to send data to modal and get data from modal in angular here is my code:
http://codepen.io/anon/pen/BNabez
var app =angular.module('ionicApp',['ionic']);
app.controller('cntr',function($scope,$http,$ionicModal){
$ionicModal.fromTemplateUrl('templates/modal.html', {
scope: $scope
}).then(function(modal) {
$scope.modalFirst = modal;
});
$scope.openmodel=function(){
// alert('d');
$scope.modalFirst.show()
}
})
You have to declare the variables in scope for that and then bind it i have edited your codepen
http://codepen.io/anon/pen/OVJGxm
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>
js:
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()
}
})