<button ng-click="btn_save">Save</button>
<button ng-click="btn_update">update</button>
I want to cach and display alert for ng-click event of btn-save only anjular js.give me some best practice for done this job.
First you need to add an app and a controller where you will implement your logic.
The aplication logic goes in the controllers. Aviod putting it in the templates.
Example:
template
<div ng-app="myApp">
<div ng-controller="MyCtrl">
<button ng-click="btn_save()">Save</button>
<button ng-click="btn_update()">update</button>
</div>
controller
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.btn_save = function(){
alert("Button save clicked!")
}
}
Is here, in the controller where you will implement the btn_save logic. In this case, the function throw an alert dialog when user clicks on button.
Here is the fiddle https://jsfiddle.net/xeq23e19/
Hope that helps.