Angular 1.4.8 inner ng-show cause an error when used in custom directive root element -
i got error when put nested ng-show attributes custom directive, 1 attribute in markup of directive , second inside root element of directive template.
my real scenario complex simplify example:
suppose have my-custom-directive below contains ng-show:
<my-custom-directive ng-show="somevalue >= 5"></my-custom-directive>
and template of 'my-custom-directive' this:
<div ng-show="options != null">my custom directive</div>
those multiple ng-show cause error.
if remove 1 of them or move inner ng-show @ least 1 level deeper in it's dom tree error gone (it's happen when it's location on root template element).
this error tested on angular v1.4.8.
is angular bug? or there reasonable explanation behavior?
here plunker example: http://embed.plnkr.co/ztzvcfc5bfmjpo9t0isw
thank in advance,
menachem
because directive has replace: true
it trying merge 2 ng-show values resulting in error. simplest solution believe replace: false
or can inject value via isolate scope , use single ng-show value within directive. believe considered cleaner solution.
example: http://plnkr.co/edit/5oc8c1hrz8n1f2klcio7?p=info
scope: { somevalue: '=somevalue' }
Comments
Post a Comment