Within my HTML view file I have a link that looks like this:
url: 'http://localhost:3000/readings?limit=100&nodeID=0001'
This is part of an Ajax call that gets readings from my local database for nodeID = 0001.
In the corresponding .js controller file I have the following function:
.controller('ReadingsViewCtrl', function ($scope, $routeParams)
{
$scope.model = {
message: $routeParams.id}
});
I can now address the ID as {{model.message}} within my HTML view file.
What I want to do is somehow embed the {{model.message}} into the URL above so that I can get readings for arbitrary nodes, i.e. have something like url: 'http://localhost:3000/readings?limit=100&nodeID={{model.message}}'
This way I can get readings for an arbitrary nodeID passed in as a parameter instead of just node 0001. How can I do this?
EDIT: As asked here is the rest of the function that contains the URL property, it is part of an Ajax call that gets data from my database.
$.ajax({
url: 'http://localhost:3000/readings?limit=100&nodeID=0001',
dataType: 'json',
type: 'get',
cache: true,
success: function(data){
var jsonobject = [];
$(data).each(function(index, value){
var list = [];
var m = moment(value.time, 'YYYY-MM-DDTHH:mm:ss.SSSZZ');
var ts = moment(value.time).valueOf();
console.log(ts);
list[0] = ts;
list[1] = value.litres;
jsonobject.push(list);
})
$('#container').highcharts('StockChart', {
rangeSelector : {
selected : 1
},
title : {
text : 'Water consumption in Litres/sec'
},
series : [{
name : 'Litres per flush',
data : jsonobject,
tooltip: {
valueDecimals: 2
}
}]
});
console.log(jsonobject);
}
});