AngularJS - Directive template dynamic -
AngularJS - Directive template dynamic -
how can create directive dynamic template?
class="lang-js prettyprint-override">'use strict'; app.directive('ngformfield', function($compile) { homecoming { transclude: true, scope: { label: '@' }, template: '<label for="user_email">{{label}}</label>', // append replace: true, // attribute restriction restrict: 'e', // linking method link: function($scope, element, attrs) { switch (attrs['type']) { case "text": // append input field "template" case "select": // append select dropdown "template" } } } });
class="lang-html prettyprint-override"><ng-form-field label="first name" type="text"></ng-form-field>
this have right now, , displaying label correctly. however, i'm not sure on how append additional html template. or combining 2 templates 1.
had similar need. $compile
job. (not sure if "the" way it, still working way through angular)
http://jsbin.com/ebuhuv/7/edit - exploration test.
one thing note (per example), 1 of requirements template alter based on type
attribute 1 time clicked save, , templates different. though, info binding, if need new template in there, have recompile.
angularjs angularjs-directive
Comments
Post a Comment