angularjs - How to add all possible attributes (including other directives) in my directive? -
i'm trying create directive so:
mytemplate.html:
<div class="mywidget"> <input type="text" class="someclass blah blah" ng-model="mymodel" ng-change="mychange" /> </div>
mydirective:
(function () { 'use strict'; angular .module('myapp.mywidgets.somewidget') .directive('somewidget', somewidget); somewidget.$inject = ['$timeout']; function somewidget($timeout) { return { restrict: 'ea', templateurl: 'mytemplate.html', link: link, require: 'ngmodel', scope: { mymodel: '=ngmodel', mychange: '&ngchange', // add other possible attributes here. dont think that's practical. } }; function link(scope, elm, attr) { } } })();
usage:
<some-widget ng-model="somemodel" .... > </some-widget>
now if want add other stuff ng-show? ng-hide? ng-change? dont think it's practical add of them 1 one. there way add them without specifying them on scope 1 one? directive used many pages can't predict other attributes or directives other people add.
thank you.
Comments
Post a Comment