I am new to Angular and am trying to do something that I just need another
set of eyes on. Here is what I am trying to accomplish:
Have a factory make an API call, then inject that factory into a parent
controller that will have scope over the entire page. Then have child
controllers nested and inherit from the parent controller.
Here is what I have so far. I may be WAY off here, and if that is the case,
please tell me. I am working on this alone, and have no help, so any help
is welcomed.
Thank you.
var app = angular.module('myApp', []);
app.factory('myFactory', function($http){
var MyFactory = function(){};
MyFactory.getParams = function(){
return $http.get('/getparameters');
.success(function(data){
var roomname = data.roomname;
})
MyFactory.getRoom(roomname);
};
MyFactory.getRoom = function(room){
return $http.get('/my/api/' + room);
};
});
app.controller('RoomCtrl', function($scope, myFactory){
$scope.data = myFactory;
});
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.