I have a rails controller for recipes. I have added some additional variable called @recID. I am able to access this variable successfully in index.json.jbuilder.
I can't figure out how to access it in my app.js (which is angular controller file).
My research has covered:
- How can i pass a scope variable from controller to directive in angular js
- How can controller talk to a directive in AngularJS?
and many other google searches.
Here is a code snippet in from app.js:
$scope.search = function(keywords) {
return $location.path("/").search('keywords', keywords);
};
// query = $resource('/', {query: "query"});
// query = $resource('/recipes/:recipeId', {
query = $resource('/', {
query: "@recID",
format: 'json'
});
console.log ("About to write to log query=" + query);
// alert ("query =<" + query + ">");
Recipe = $resource('/recipes/:recipeId', {
recipeId: "@id",
format: 'json'
});