javascript - AngularJs: Applying ng-class for input element in a directive -
i trying enhance our directive. used 1 input type='submit' class="btn" element , directive had replace: "true". i've changed template directive following:
<input type="submit" value="{{value}}" id="btnchoose" ng-class="{{ngclass}}" style="width: 85% !important; margin-top: 0;" class="btn_file_select" ng-click="click()" />
(showing top part of html). changed replace false , added ngclass: '@' directive.
in form set ng-class , can see set when inspect element using dev. tools. can see same ng-class expression added button. however, doesn't work , it's not being evaluated.
how should update directive able receive ng-class property on parent's div in form , pass button?
sample of using directive in form right now:
<data-desc:type ng-class="{greentext: (currentsalespoint['lremotes' + n] == 0 && metadata.layouts['dlrs' + n] > 0)}" title="{{ '@string.format(labels.selectx, labels.printer)'}}" do-search="popup()" value="{{currentsalespoint['lremotes'+ n] == 0 ? (metadata.layouts['dlrs' + n]==0?'@string.format(labels.selectx, labels.printer)':metadata.layouts['dlrs' + n + 'text']) : currentsalespoint['lremotes'+ n + 'text']}}" param="layouts" filter-by="remote printer" message="@string.format(labels.selectx, labels.printer)" selected="currentsalespoint['lremotes'+ n]" descrip-value="descrip" type-value="'lremotes'+ n" description="currentsalespoint['lremotes'+ n + 'text']"></data-desc:type>
and directive has following @ top:
return { restrict: 'e', transclude: true, replace: false, scope: { title: '@', message: '@', param: '@', selected: '=', description: '=', value: '@', descrip: '=', type: '=', ngclass: '@', dosearch: '&', filterby: '@?' },
change "@" "=" , change ng-class="{{something}}"
ng-class="something"
, , don't use ngclass
name of scope property.
embedding interpolated values inside of expressions considered bad practice per this: https://docs.angularjs.org/guide/interpolation#known-issues
Comments
Post a Comment