我想制作自己的标签maanger。我使用bootstrap typeahead并将指令添加到此元素并在select操作上侦听广播。我努力在其中添加带变量的btn,但我还没有找到将它放入输入字段的方法(并支持拉伸)
如何将$scope.item
放入angular.element("<div>{{$scope.item}}</div>")
?
mainApp.directive("tagsManager", ['$compile', function($compile) {
return {
restrict: 'A',
link: function( scope, element, attrs ) {
console.log("Tags in directive: " + scope.tags);
scope.$on('tags.new', function(event, tag) {
console.log("New tag is arrived: " + tag.name);
var el = angular.element("<div class=\"btn btn-default\">tag.name</div>");
// $scope.items = teamSharedObj.teams;
$compile(el)(scope);
element.after(el);
});
}
}
}])