I am making an application. I have a form where the user can type in a product. I get the price with an angularjs service. I inject it in. RateInfoService.
So if I type in "Milk" it will say in the DOM {{rate}} -> $2But if I fill in chips, it will change offcourse to {{rate}} -> $1.50
But what I want to fill in Milk and after that Chips. So I want it to show in the html page
Milk->$2 & Chips->$1.50.
So it will show both items, the user can keep typing in products and submitting it. (ng-click). I might be able to do that in an array but note that I have a refresh rate. Not sure if that's possible to do with an ng-repeat or even if that is possible.
.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>
Also some extra info
$scope.submit = function() {
$scope.alarmingMarket = $scope.hard
console.log($scope.monitors);
};
$scope.alarmingMarket = $scope.hard
I used this so it would only get the market price after the user has filled in & pressed submit.
RateInfoService to get the price: http://pastebin.com/gHfhzMjR
I just found out it's possible to dump multiple objects in the url.
https://query.private%20in%20("Milk","Chips")&format;=json&diagnostics;=true&env;=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback;=How can I do this the best way in angular? i'm new in angularjs (3 weeks)
this is the Json formatted view (Explains the $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 hope this was enough info. *** Not sure why the styling goes wrong. Sorry for the messy page. Stack overflow gives a good preview of this post, but something goes wrong when I publish it. A lot of the code isn't greyed out