AngularJS: how to use a factory with two-way data binding

Viewed 5747

EDIT: Working plunker: http://plnkr.co/edit/iInh7TnbGvSHSPOWuWPk?p=preview

====================================================================

In the following plunker: http://plnkr.co/edit/TIfkYE?p=preview

A very simple example compares the usage of a factory and a service. Two way data-binding works using the service but not the factory. Why?

With the service:

<button btn-radio="item.nb" ng-model="fromService.current>

clicking the button correctly updates the property current of the service fromService.

However, using a factory:

<button btn-radio="item.nb" ng-model="fromFactory.current>

clicking the button does not update the property current of the factory fromFactory.

My use case is the following: I want to use a service/factory to share data across controllers and other services.

I have read a lot references, including:

2 Answers
Related