我有一個輸入字段。使用動態添加的按鈕聚焦工具提示彈出窗口。如何使該按鈕工作點擊?如何讓ng-click在動態添加按鈕上工作?
我一直在尋找解決方案,但沒有任何明確的具體例子。
這裏是我的plunkr:http://plnkr.co/edit/UFv6qcg68wD99HXf76xP?p=preview
下面是代碼:
<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>
控制器
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');
});