Sharing data between AngularJS controllers but having the shared data come from an Ajax call

后端 未结 2 1964
夕颜
夕颜 2021-02-20 07:32

I\'ve figured out how to share data between two AngularJS controllers using a shared service in the contrived example below:

(Functioning fiddle)

var app         


        
2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-20 08:08

    I've created this example that shows how to fetch, store and share data (models) across different controllers without loosing its bindable functionality.

    Live Example: http://pablodenadai.github.io/SharingModelsAngularJS/

    Source code 1: (Resources and Model abstraction) https://github.com/pablodenadai/SharingModelsAngularJS/blob/master/app/scripts/controllers/main.js

    Repo: https://github.com/pablodenadai/SharingModelsAngularJS

    Hope it helps.

提交回复
热议问题