[英]How to write a function in Ionic popover ?
這是我的離子彈出腳本:
$scope.popover = $ionicPopover.fromTemplateUrl('templates/demo.html', {
scope: $scope,
controller: [$scope,function($scope){
$scope.savePost=function(){
console.log ($scope.$scope.savePost)
}
}]
}).then(function(popover){
$scope.popover = popover;
})
這是我的demo.html
<ion-popover-view>
<ion-content>
<div class="list">
<button class="item" ng-click=savePost()>Save</button>
</div>
</ion-content>
</ion-popover-view>
但是我想將此函數放在代碼中,但我不確定將其放在哪里。
$scope.savePost=function(){
//do something
console.log ('this is the save post function)
}
只需將下面的代碼放入,因為它仍在同一控制器的$scope
中:
$scope.popover = $ionicPopover.fromTemplateUrl('templates/demo.html', {
scope: $scope,
controller: [$scope,function($scope){
$scope.savePost=function(){
console.log ($scope.$scope.savePost)
}
}]
}).then(function(popover){
$scope.popover = popover;
})
// savePost() function
$scope.savePost=function(){
//do something
console.log ('this is the save post function)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.