Promise sample for Cross-Platform mobile application class

Size
2,214 Kb
Views
30,360

How do I make an promise sample for cross-platform mobile application class?

What is a promise sample for cross-platform mobile application class? How do you make a promise sample for cross-platform mobile application class? This script and codes were developed by Aaron K Saunders on 25 September 2022, Sunday.

Promise sample for Cross-Platform mobile application class Previews

Promise sample for Cross-Platform mobile application class - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Promise sample for Cross-Platform mobile application class</title>
</head>
<body> <html> <head> <title>Simple App - Binding</title> <!-- see https://getbootstrap.com/css/ --> <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script> </head> <body ng-app="smallApp" class="container" > <div ng-controller="MyController"> {{ progress }} </div> </body>
</html> <script src="js/index.js"></script>
</body>
</html>

Promise sample for Cross-Platform mobile application class - Script Codes JS Codes

//
// Promise sample for Cross-Platform mobile application class
//
// promises as an alternative to callbacks as a primier for
// discussing promise in $http and angular-resource
// create the angular app module
angular.module('smallApp',[])
// create the angular controller module .controller( 'MyController', function ($scope, $q) { $scope.progress = []; function logInToSystem() { var deferred = $q.defer(); deferred.resolve("logged in"); return deferred.promise; } // use the information from previous call ( logInToSystem ) // to process checkForData, promises return one object which // will be passed to the next promise/function in the chain function checkForNewData(_loginInfo) { var deferred = $q.defer(); $scope.progress.push(_loginInfo) deferred.resolve("got the data"); // if reject, the error will get caught // in the catch block and processing will // end - deferred.reject("got the data"); return deferred.promise; } // now that you are loggedin and you have the // data you can actually display the data function displayTheData(_newDataInfo) { var deferred = $q.defer(); $scope.progress.push(_newDataInfo) deferred.resolve( "this is the data"); return deferred.promise; } // there are a set of steps that have a dependency on one // another, we can manage that process through promises return logInToSystem() .then(checkForNewData) .then(displayTheData) .then(function(_response){ $scope.progress.push(_response) }).catch(function(_error){ alert("Error Processing data " + _error); });
});
Promise sample for Cross-Platform mobile application class - Script Codes
Promise sample for Cross-Platform mobile application class - Script Codes
Home Page Home
Developer Aaron K Saunders
Username aaronksaunders
Uploaded September 25, 2022
Rating 3
Size 2,214 Kb
Views 30,360
Do you need developer help for Promise sample for Cross-Platform mobile application class?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Aaron K Saunders (aaronksaunders) Script Codes
Create amazing Facebook ads with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!