angularjs - How do I pass and then access an object inside a directive template (directive uses isolate scope)? -


i have collection of navbaritems , presenting them this:

 <a data-role="button" data-iconpos="notext" ng-show="navbaritems['search'].show" ng-click="navbaritems['search'].click()" data-icon="{{navbaritems['search'].icon}}">{{navbaritems['search'].title}}</a> 

i'm repeating code , changing 'type', i'd create directive template , call this:

<navbaritem type="search"></navbaritem> 

i've tried passing attribute isolated scope can't navbaritems once in directive.

as mentioned in comment above, since isolate scope being used/created, other data isolate scope requires need passed directive via additional attributes on same element. in case navbaritems needs specified:

<navbaritem type="search" items="navbaritems"></navbaritem> 

since navbaritems object (not string), = syntax should used in isolate scope definition:

scope: { items:'=',  ... }, 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -