Create a button that, when clicked, triggers a function to display an alert using angular js

<div ng-app="eventApp" ng-controller="EventController">
    <button ng-click="showAlert()">Click me</button>
</div>

<script>
    var app = angular.module('eventApp', []);
    app.controller('EventController', function($scope) {
        $scope.showAlert = function() {
            alert('Button clicked!');
        };
    });
</script>

 

Post your Answer