I am new to Angular and quite frankly Java Script in general. I have been building a prototype app from some examples and tutorials and have run into a presumably simple issue that can be solved by passing parameters.
I want to receive a parameter in my controller (myKey) and pass it along to the factory which in turn will pass it along to a web API. I can define a constant for myKey in the factory and have everything work, I am having an issue in passing a parameter along.
Sorry for the newbie question and yes I have more study to do.
Thanks
'use strict';
/* Factories */
angular.module("myApp.myViewer.factories", []).factory('myThings', ['$resource',
function ($resource) {
var resource = $resource('/api/myThings', {}, { get: { method: 'GET', params: { myKey:"M1234" } } });
return resource;
}
]);
/* Controllers */
angular.module("myApp.myViewer.controllers", [])
.controller('myCtrl', ['$scope', 'myThings', function ($scope, myThings) {
myThings.get(function (response) {
console.log(response);
$scope.myThing = response;
});
}]);
ng-submitorng-modelcorrectly.