jquery - Unable to pass resolved parameter from controller -
the page not loading @ all. m trying resolve http service.
my factory :
app.factory("search", function($q, $http, $cookiestore){ return { getmessage: function(){ //return $q.when("response"); console.log("cookie --> ".$cookiestore.get("sid")); var promise = $http.post('tpl/processors/process-contacts.php', {sid : $cookiestore.get("sid")}).then(function(response) { return response.data; }); return promise; } } });
my state resolve:
.state('app.mail.compose', { url: '/compose', templateurl: 'tpl/mail_new.php', reloadonsearch: true, resolve: { searchval: ['search', function (search) { return search.getmessage(); // not }] } })
my controller :
app.controller('smsnewctrl', ['$scope','$http','$cookiestore','$stateparams','searchval', function($scope, $http, $cookiestore,$stateparams,searchval,transformrequestasformpost) { $scope.sid = $cookiestore.get("sid"); //console.log("inbox type : "+ $stateparams.inboxtype ); console.log("cookie call inside smsnewctrl: ",$cookiestore.get("sid")); $scope.contacts = searchval; console.log("contacts search factory :" + $scope.contacts); $scope.mail = { to: '', content: '' } }]);
earlier used http call inside controller. till worked fine page loaded first , data came after that. wanted resolve data doing http call outside controller. m new angular , still learning, please let me know if approach wrong or let me know best way http post outside controller , resolve.
i wrote quick example working: http://jsbin.com/nuzaqugofu/1/edit?html,js,console
try way did , keep adding more , more of code until not work anymore. know causing problem.
Comments
Post a Comment