Я собирался использовать Plunker, чтобы помочь мне в тестировании директивы, но сначала я просто хотел создать один, чтобы протестировать плункер, работая, поэтому я ввел примерный код. Угадайте, что, основные директивы не работают, и я понятия не имею, почему.Почему мои директивы не работают в Plunker?
Мои директивы:
app.directive('attributeDirective', function() {
return {
restrict: 'A',
link: function(scope, iElement, iAttrs) {
iElement.bind('click', function() {
console.log('clicked attributeDirective');
});
iElement.bind('mouseover', function() {
iElement.css('cursor', 'pointer');
});
}
};
});
app.directive('elementDirective', function() {
return {
restrict: 'E',
replace: true,
template: '<h2>this is elementDirective</h2>',
link: function(scope, iElement, iAttrs) {
iElement.bind('click', function() {
console.log('clicked elementDirective');
});
iElement.bind('mouseover', function() {
iElement.css('cursor', 'pointer');
});
}
};
});
Мой HTML:
<body ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
<h2 attributeDirective>Here is my attribute directive</h2>
<elementDirective></elementDirective>
</body>
Пожалуйста, посмотрите на это [вопрос] (https://stackoverflow.com/questions/31001134/how-to-create-network-graph-or-hierarchical-tree-using-visjs-in -angularjs) здесь мой [plunker] (http://plnkr.co/edit/SKfNdsw9g9aCG6wZsQNZ?p=preview) не работает. Пожалуйста помоги. – Ricky