S
S
Sergey2015-09-24 01:12:38
JavaScript
Sergey, 2015-09-24 01:12:38

Why is id not caught?

I'm making a directive that displays the id of the svg part when clicked.

(function () {
    'use strict';

    angular
            .module('plunker')
            .directive('svgMap', svgMap);

    function svgMap() {
        var directive = {
            link: link,
            templateUrl: 'test.svg',
            restrict: 'EA',
            
            transclude: true

        };
        return directive;

        function link(scope, element, attrs) {
            scope.elementId = element.attr("id");
            scope.regClick = function () {
                console.log(scope.elementId);
            };

        }
    }
})();

in path svg I do ng-click="regClick()"In each path there is an id. But you are driving undefined. What have I done wrong?
plnkr.co

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
littleguga, 2015-09-24
@TsarS

You can try like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question