In my app I'm reading an URL parameter which I'd like to pass to my Angular controller, which will then load a JSON file.
For example index.html?id=1234
should make make the controller load data/1234.json
My current code results in an injector error:
var id = getUrlParam('id')
app.controller('myController', function ($scope, $http, id) {
$http.get("data/"+id+".json").then(function(res) {
$scope.posts = res.data
})
});
What am I doing wrong?