javascript - what if I want to create directive that match only for custom element && atribute -
let assume want create directive matched element match aminput[type=dropdown] how can that?
i can example:
.directive('aminput',function () { return { restrict: "e", scope: { data:'@' }, compile:function(telement, tattrs){ if (tattrs.type != 'dropdown') return; return function link ($scope, element, attr, ctrl) { var parseresult = parse($scope.data); } } } }); but if define directive isolate scope am-input[type=checkbox]
.directive('aminput',function () { return { restrict: "e", scope: { data2:'@' }, compile:function(telement, tattrs){ if (tattrs.type != 'checkbox') return; return function link ($scope, element, attr, ctrl) { var parseresult = parse($scope.data2); } } } }); angular#$compile throw exception 2 directives define isolate scope.
error: [$compile:multidir] multiple directives [aminput, aminput] asking new/isolated scope on: <am-input type="checkbox"></am-input>
directive name should unique (as long match same restrict) in case should merge them one.
(just reference, might help: angular directive name: lower case letters allowed?)
Comments
Post a Comment