AngularJS - HTML под моей директивой не отображается
Пожалуйста, смотрите соответствующие jsFiddle
В этом файле у меня есть два диапазона 'test1' и 'test2'. Показывается диапазон «test2», но диапазон под моей пользовательской директивой «test1» вообще не отображается или не вызывается на странице. Зачем?
<div ng-app="HelloApp">
<div ng-controller="MyCtrl">
<search-bar/> <!-- The Search Bar Directive -->
<span>test1</span>
</div>
<span>test2</span>
</div>
Угловой код
var app = angular.module('HelloApp', [])
app.directive('searchBar', function() {
return {
restrict: 'AE',
replace: true,
template: '<input type="text" ng-model="searchData" placeholder="Enter a search" id="searchbarid" />',
link: function(scope, elem, attrs) {
elem.bind('keyup', function() {
scope.$apply(function() {
scope.search(elem);
});
});
}
};
});
app.controller('MyCtrl', function($scope) {
var items = ["ask","always", "all", "alright", "one", "foo", "blackberry", "tweet","force9", "westerners", "sport"];
$scope.search = function(element) {
$("#searchbarid").autocomplete({
source: items
});
};
});