My issue is as follows: I am attempting to call a resource with a specific parameter, but I keep encountering the following error:
[$resource:badcfg]
I have spent the last 3 hours trying to resolve this, but to no avail. When I call the resource like this:
$scope.komintent = Fakturi.komintenti.get({ id: 1 });
it works perfectly fine, however, I need to pass a dynamic id. This is why I am trying to invoke it like this:
$scope.komintent = Fakturi.komintenti.get({ id: $scope.faktura.KomintentID });
Above this line, I have the following code (both lines together):
$scope.faktura = Fakturi.fakturi.get({ id: $routeParams.id });
$scope.komintent = Fakturi.komintenti.get({ id: $scope.faktura.KomintentID });
Despite trying numerous solutions, I have been unable to make it work.
Interestingly, I have another similar example where everything works as expected: I can use both parameters as $scope.x.y
Fakturi.fakturaKomintent.update({ Fid: $scope.faktura.DokumentID, id: $scope.komintent.KomintentID });
I even tried setting isArray: false, but it didn't help. Here is my web API code: http://prntscr.com/7k6wwt
Even after trying with and without [Route]
, the issue persists.
Another attempt:
$scope.kom = function () { Fakturi.komintenti.get({ id: $scope.faktura.KomintentID }, function success(data) { $scope.komintent = data }); }
Followed by
input ng-click="kom()"/>
works fine when called, but I prefer it to initialize on page load
It works with $routeParams.id instead of $scope.faktura.KomintentID, but the id is not what I need
Here is a screenshot from the resource factory: http://prntscr.com/7k7bs2
*Another strange observation: When I place the line in a watchGroup, it works perfectly. However, the page flickers when I type something because it keeps refreshing, although it doesn't throw any errors.