angularjs - Pass expression to directive for transclusion -
i have directive uses template generate typeahead in form associated label , css classes.
<div class="form-group" ng-class="{ 'has-success': hassuccess(field), 'has-error' : haserror(field) }"> <label class="control-label" for="{{ field }}"> {{ label }} </label> <input type="text" class="form-control" ng-model="model" name="{{ field }}" id="{{ field }}" typeahead="{{ items }}" required> </div>
this created using following markup:
<fe-ta model='model.state2' label='state' items='s in states'></fe-ta>
the problem expression passed items
. following exception:
syntax error: token 'in' unexpected token @ column 3 of expression \ [s in states] starting @ [in states].
my directive takes items
in isolate scope expression &
.directive('feta', function() { return { restrict: 'e', require: ['^form', '^feform'], scope: { model: '=', label: '@', items: '& }, templateurl: 'typeahead.tmpl.html', replace: true, link: function (scope, element, attrs, controllers) { var feformcontroller = controllers[1]; scope.field = attrs.model.substring(attrs.model.indexof('.') + 1); scope.hassuccess = feformcontroller.hassuccess; scope.haserror = feformcontroller.haserror; } }; });
how can pass expression directive?
plunker here: http://plnkr.co/edit/ivvjzuoxkgsaqqgzdpl0?p=preview
Comments
Post a Comment