2016-10-14 5 views
0

これは私のイオンポップオーバースクリプトです:イオンポップオーバーで関数を書くには?

$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) 

} 

答えて

1

ただ、同じコントローラで$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) 

} 
+0

は非常にあなたがupvoteすることができます – noor

+0

をお願いします。 – Nere

+0

ありがとうございました。あなたは大歓迎です。 – Nere

関連する問題