I am attempting to include additional 'model' objects that are useful in my Angular application. Suppose I have two separate javascript files as shown below. I would like to add a "createStudent" function to my teacher prototype, and have it call the student constructor method. How can teacher.js correctly reference student.js? What is the method for injecting that here?
FYI, I know there are many methods for including rich object models in Angular. I don't want to go the route of using Restangular at the moment for example. I want to keep this extremely simple at the moment, and hopefully increase my understanding of angular modules.
Thanks!!
---------- teacher.js -----------
(function() {
var teacherConstructor = function() {
var teacher = {
student: []
};
return teacher;
};
var module = angular.module("MyApp.models");
module.value("teacber", teacberConstructor);
}());
---------- student.js
(function() {
var studentConstructor = function(theTeacher) {
var student = {
myTeacher: theTeacher
};
return student;
};
var module = angular.module("MyApp.models");
module.value("student", studentConstructor);
}());