Is there a way to automatically refresh the variable assigned in data-ng-init whenever the source data changes, without having to do it through the controller?
I'm looking for a directive that can achieve this. Any suggestions or examples would be appreciated.
To illustrate, take a look at the sample demo below which features sections for both Cars and Bikes. When you click "Add Car," the listing and counts get updated as expected since it's directly from the source data.
However, when you click "Add Bike," the bikeData variable does not get refreshed as it still holds the initial JSON value only.
data-ng-init="bikeData = (sorted | filter: { type: 'bike' }:true)"