I am using ngDialog, https://github.com/likeastore/ngDialog#api
this is in my controller:
$scope.clickToOpen= function(){
ngDialog.open({
template:
'<button ng-click=savePost()> + Save</button>' ,
plain: true,
className: 'ngdialog-theme-default'
})
}
and HTML is
<button class="ion-android-more-horizontal" ng-click="clickToOpen()"></button>
the words 'save' is supposed to call the savePost function but it's not working
The problem with your modal is not the ng-click, but the savePost function that is undefined inside the scope of your modal.
After looking at source code, it doesn't seem to have a way to share a function between a controller displaying the modal, and the modal itself.
What you need to do is to add a controller to your modal, and add there your modal logic :
$scope.clickToOpen= function(){
ngDialog.open({
template:
'<button ng-click=savePost()> + Save</button>' ,
plain: true,
className: 'ngdialog-theme-default',
controller: ['$scope', function($scope){
$scope.savePost = function(){
alert("this one can be triggered by your template");
};
}]
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.