Reputation: 681
This is my ionic popover script :
$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;
})
and this is my demo.html
<ion-popover-view>
<ion-content>
<div class="list">
<button class="item" ng-click=savePost()>Save</button>
</div>
</ion-content>
</ion-popover-view>
but I want to put this function in the code but I am not sure where to put it.
$scope.savePost=function(){
//do something
console.log ('this is the save post function)
}
Upvotes: 0
Views: 186
Reputation: 4097
Just put your code as below since it still in $scope
in the same controller:
$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)
}
Upvotes: 1