I am working on developing an application that involves a form where users can input products. Using an AngularJS service called RateInfoService, I retrieve the price information and inject it into the DOM. For example, if the user types in "Milk," the displayed rate will be {{rate}} -> $2.
If the user then fills in "Chips," the rate will adjust accordingly to {{rate}} -> $1.50.
However, my goal is to allow users to input multiple products consecutively and see them all listed on the page. So, ideally, after typing in Milk followed by Chips, the display should show: Milk->$2 & Chips->$1.50.
To achieve this functionality, I am considering using an array to store the entered products for further processing. One challenge I anticipate is managing the refresh rate while updating the data seamlessly.
.controller("MainCtrl", function($scope, $http, $timeout, $ionicPlatform, $cordovaLocalNotification, $ionicPopup, RateInfoService, AlarmService, MonitorService) {
$scope.refreshRate = 5000;
$scope.refreshData = function() {
RateInfoService.getMarket($scope.alarmingMarket).success(function(data) {
$scope.rate = data.query.results.rate.Rate;
$scope.updateTime = data.query.results.rate.Time;
})
}
<label class="item item-input">
<span class="input-label">Product name</span>
<input type="text" min="3" ng-model="hard" name="text" autofocus required>
</label>
Additionally, when a user submits a product, the following function is triggered:
$scope.submit = function() {
$scope.alarmingMarket = $scope.hard
console.log($scope.monitors);
};
The line "$scope.alarmingMarket = $scope.hard" ensures that market data is fetched only after the form submission.
For retrieving the price data, I rely on the RateInfoService: http://pastebin.com/gHfhzMjR
Recently discovered the possibility of including multiple objects in the URL link:
https://query.private%20in%20("Milk","Chips")&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=My main query revolves around implementing this feature efficiently within AngularJS as I am relatively new to this framework (3 weeks).
This section illustrates the JSON formatted view - explaining the line "$scope.rate = data.query.results.rate.Rate;" "results": {
"rate": [
{
"id": "MILK",
"Name": "MILK",
"Rate": "1.1054",
"Date": "10/26/2015",
"Time": "9:37pm",
"Ask": "1.1056",
"Bid": "1.1052"
},
{
"id": "CHIPS",
"Name": "CHIPS",
"Rate": "1.5349",
"Date": "10/26/2015",
"Time": "9:37pm",
"Ask": "1.5352",
"Bid": "1.5346"
I trust this provides adequate insight. *** Apologies for any formatting issues experienced. Despite a clear preview on stack overflow, certain elements may not render correctly upon publishing. Some code sections might lack proper highlighting.