Popover call to server

Popover call to server

by User888

HTML

<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.1/angular.min.js"></script>
<div ng-app ng-controller="SendController">
  <button class="btn"><span class="glyphicon glyphicon-send test"></span></button>
</div>

JavaScript

function SendController($scope) {
  $scope.msg = 'sending...';
  $scope.str = '<div><p><input type="button" id="smt" name="smt" value="Send" /></p><div>status = ' + $scope.msg + '</div></div>';

  $('.test').on("click", function(event) {
    event.preventDefault();
    $(this).popover({
      html: true,
      trigger: 'click',
      content: $scope.str,
      placement: 'right',
      title: 'Send to backend'
    });
    $(this).on('shown.bs.popover', function(e) {
      $("#smt").click(function() {
        console.log("sending to backend....");
        $scope.msg = 'Successful...';
        $scope.$apply();
      });
    });
  });
}