I have made a directive that makes a dropdown and populates it from an API. It works. However when I used this directive multiple times in a view it makes multiple calls to the API to populate the dropdown.
So I was wondering if there was some simple way to avoid that. The not so simple way would be to put the $http into a service that does caching somehow.
Directive
app.directive('dropdown', function() {
return {
// omitted...
controller: function($scope, $http) {
$http.get("...")...;
}
};
});
View
<dropdown></dropdown>
<dropdown></dropdown>