javascript - Supplying remote data to directives in AngularJS -


when developing directives seems best practice seperate data / model actual directive.

for example if have directive called "event" e.g.

<div class="event">     <h1>{event.title}</h1>     <small>{event.startdate}</small> </div> 

what best way supply data directives in reusable pattern? through service?

there lot can directives. lot of ways can work data. more direct way pass data or references directive. take @ link below reference. example code, following:

<div dir-event event-title="context.title" event-start="context.startdate" ></div> 

in html, context.title , context.startdate objects on controller. directive:

app.directive("direvent", function() {     return{         restrict: "a",         scope:{             title:"=",             startdate:"="         },         transclude: true,         template: "<div class='event'><h1>{{title}}</h1><small>{{startdate}}</small></div>",         replace: true     } }); 

directives


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -