Reputation: 692
I want to append html tag to every element in id and show it in text box like 1 x
,2 x
,3 x
.(x
is close button using ×
)
I am using the following code.
My html tag
<input type="text" id="receiver" class="form-control input-sm" ng-model="to" />
Angularjs controller
$scope.to="";
$scope.id=[1,2,3];
$scope.append = function ($event) {
$scope.to=$scope.to+id[0]+('<div class="close" data-dismiss="modal">×</div>');
}
But I am getting following output :
1 <div class="close" data-dismiss="modal">×</div>
,2<div class="close" data-dismiss="modal">×</div>
,3<div class="close" data-dismiss="modal">×</div>
Can any one help me.
Upvotes: 1
Views: 563
Reputation: 1113
You have two issues with your solutions:
ng-bind-html
directive inside of ng-model
. Don't forget to declare ngSanitize as a module dependency.1 x
, 2 x
...is not an input
.Upvotes: 1