Đây là what I've got cho đến thời điểm này. Đầu tiên là kịch bản:Cách giao tiếp thành ngữ giữa cửa sổ Onsen và bố mẹ là gì?
ons.bootstrap();
.controller('AppController', function($scope) {
$scope.greeting = "Hello!";
ons.createPopover('popover.html').then(function(popover) {
$scope.popover = popover;
popover.on('preshow', function() {
popover._scope.greeting = $scope.greeting;
});
popover.on('posthide', function() {
$scope.greeting = popover._scope.greeting;
$scope.$apply();
});
});
});
Và trang:
<ons-page ng-controller="AppController">
<ons-toolbar>
<div class="center">Popover</div>
</ons-toolbar>
<div style="margin-top: 100px; text-align: center">
<ons-button modifier="light" ng-click="popover.show($event)">Show popover</ons-button>
</div>
<div style="margin-top: 100px; text-align: center">{{greeting}}</div>
</ons-page>
<ons-template id="popover.html">
<ons-popover direction="up down" cancelable>
<div style="text-align: center; opacity: 0.8;">
<input style="margin: 20px" type="text" ng-model="greeting" />
</div>
</ons-popover>
</ons-template>
Điều này dường như làm việc cho tôi, nhưng tôi không chắc chắn về phần popover._scope
. Có phải nó được truy cập như thế không? Tôi dường như không tìm được cách nào khác.
Vậy cách thức thành ngữ để làm điều này là gì? Và một số ví dụ tốt là gì?
Cảm ơn bạn.
Câu trả lời là khai sáng, nhưng hơi khác với những gì tôi muốn: Điều gì xảy ra nếu tôi muốn giá trị được cập nhật trên sự kiện ẩn cửa sổ bật lên? –