Wednesday 15 May 2013

javascript - angularjs passing parameter to modal after create -



javascript - angularjs passing parameter to modal after create -

function maincontroller($modal){ var modaloptions = { templateurl: 'templates/mytmp.html', controller: 'mycontroller', size: size, resolve: { items: [1,2,3] } }; $modal.open(modaloptions); }

i using default modal of angularjs , passing parameter [1,2,3].

but want phone call 3 http request in maincontroller , pass records modal. request results coming async. how can this?

function maincontroller($modal, $http){ $http("gettwitterfriends").success(ontwittersuccess); $http("getfacebookfriends").success(onfacebooksuccess); $http("getgmailplusfriends").success(ongmailplussuccess); // want list of these records on modal. }

return promises factories , chain async calls have sync effect, record, force items array , request next record. repeat this. when records retrieved , pushed modaloptions, open modal.

function maincontroller($modal){ var modaloptions = { templateurl: 'templates/mytmp.html', controller: 'mycontroller', size: size, resolve: { items: [] } }; $http("gettwitterfriends").then(function(record1){ //get first record modaloptions.resolve.items.push(record1); $http("getfacebookfriends").then(function(record2){ //get sec record modaloptions.resolve.items.push(record2); $http("getgmailplusfriends").then(function(record3){ //get 3rd record modaloptions.resolve.items.push(record3); $modal.open(modaloptions); //open modal } }); }); }

javascript angularjs

No comments:

Post a Comment