javascript - Pushing promise data to an array -
I'm probably not using the promise correctly, but I defined a service in my controller (a separate factory ) Calling such as,
_ ($ $ Scope.aap.idList, function (id) {MyService.getItems ($ stateParams.name, id). $ Promise. Then (function (scan) {If (scan.length! == 0) {addToList ( Scan);}})}); Var addToList = function (item) {$ scope.aap.scans.push (_.clone (item)); Return $ scope.aap.scans; }; The service is defined as:
service.getItems = function (name, id) {var items = $ resource ('/ proj / Rs / pr / elems / getItems', {id: id, name: name}, {query: {method: 'get', isArray: true, transformResponse: function (scans) {var items = angular.fromJson (scans) ; _ Each (item, function (scan etc) {scanItem.checked = false;}); return item;}}}); Return items .query (); Now, in MyService.getItems I can add console.log (scan) and passing the appropriate objects , But it will not add these items to my list. Do I need some more way about this?
Comments
Post a Comment