你有餘地,要聲明變量,然後將其綁定 我已編輯您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()
}
})
@ f5ed你能解釋更多 – user944513
以及你已經綁定到輸入{{input.saySomething}}所以它指的是財產的對象輸入NG saySomething -model將創建變量/屬性(如果在範圍中不可用),但它不能創建對象及其屬性(我認爲),因此您需要爲範圍內的對象定義 –
行得通! – user944513