How to load angular date filter on success of REST call or after an event broadcast
<p>I have a REST api which gives me date-format (along with other data). I want this date-format to be used in my custom date filter, so that I can use this filter in my view.</p>

<p>My view is something like this.</p>

<p><code>&lt;span&gt;{{vm.filters.fromDate | dateFilter}}&lt;/span&gt;</code></p>

<p>My filter is like this.</p>

<pre><code>.filter('dateFilter', function( $filter, commonService ) {
      var dateFormat = commonService.getDateFormat();
      return function( inputDate ) {
          return $filter('date')( inputDate, dateFormat );
      };
 })
</code></pre>

<p>There is another setter for date-format in commonService <code>commonService.setDateFormat( dateFormat )</code> which executes on success of the REST call.</p>

<p>But in my case, filter is executing before I get the response from api, so it couldn't get any date-format from commonService through <code>commonService.getDateFormat()</code> in filter implementation. Hence wrong date-format is reflecting on UI.</p>

<p>What is the best way to execute/ load a angular filter on success of something or on broadcast of an event?  </p>