AngularJS : How would i return value from factory if the data is fetched with http
问题 I have this factory in angular: 'use strict'; angular.module('finansiiApp') .factory('transactions', function ($http) { var transactions = []; $http.get("/api/transactions.json") .success(function(data, status){ transactions = data; }); // Public API here return { getTransactions: function () { return transactions; }, addTransaction: function(transaction){ transactions.push(transaction); } }; }); This is my controller: 'use strict'; angular.module('finansiiApp') .controller('MainCtrl',