Q:

How to make ng-click working on dynamically added button?

I have an input field. On focus a tooltip popups with a button that was added dynamically. How to make ng-click on that button working?
I was looking for solutions, but there is no any clear concrete example.
here is my plunkr: http://plnkr.co/edit/UFv6qcg68wD99HXf76xP?p=preview
Here is the code:
<body>

<div ng-controller="PopoverDemoCtrl">
    <h4>Dynamic</h4>

    <p>{{message}}</p>

    <br><button class="btn btn-warning" ng-click="removeMessage()">Remove mesage</button>

    <br><br>
    <input type="text" value="Click me!" uib-popover-html="htmlPopover" popover-trigger="focus" class="form-control">
    popover-trigger="focus" class="form-control">-->
</div>
</body>
</html>

controller
angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('PopoverDemoCtrl', function ($scope, $sce) {

$scope.dynamicPopover = {
    content: 'Hello, World!',
    templateUrl: 'myPopoverTemplate.html',
    title: 'Title'
};

$scope.message = '';

$scope.showMessage = function(){
  console.log("Simple message");
  $scope.message = "Just added text";
}

$scope.removeMessage = function(){
  console.log("Simple message");
  $scope.message = "";
}

$scope.test = function(){
    console.log("test me click")
}

$scope.placement = {
    options: [
        'top',
        'top-left',
        'top-right',
        'bottom',
        'bottom-left',
        'bottom-right',
        'left',
        'left-top',
        'left-bottom',
        'right',
        'right-top',
        'right-bottom'
    ],
    selected: 'top'
};

$scope.htmlPopover = $sce.trustAsHtml('<button ng-mousedown="test()"><b style="color: red">Add message</b></button> to the <div class="label label-success">page</div> content');

});

A:

Replace uib-popover-html to uib-popover-template and use ng-click instead of ng-mousedown and give little delay to close the popop
<input type="text" ng-model="value" value="{{value}}" uib-popover-template="htmlPopover" popover-trigger="focus" popover-popup-close-delay="1000" class="form-control">

<script type="text/ng-template" id="myPopoverTemplate.html">
  <div>
    <button ng-click="test()"><b style="color: red">Add message</b></button>
    <div class="label label-success">page</div>
  </div>
</script>

sample working code. 
http://embed.plnkr.co/deN1VjHdXbTKXlqdQ0vt/ 
More info regarding Uib https://angular-ui.github.io/bootstrap/#/popover

