In app.js
I have:
(function(){
var app = angular.module("myApp", []);
})();
in process.js
which is included after app.js
I have:
(function(){
app.controller('ProcessController', ['$http', function($http){
this.something = "Test"
}]);
});
and in my HTML
file I have a div
<html class="no-js" lang="en" ng-app="myApp">
...
<div class="row" ng-controller="ProcessController">
This is throwing an error in my console:
Error: [ng:areq] Argument 'ProcessController' is not a function, got undefined
I'm pretty new to angular and have never used multiple files like this before. What am I doing wrong?
Use angular.module("myApp")
inside other JS file & don't forget to call function which will make sense to have IIFE pattern, which will help you to make ProcessController
controller available.
Code
(function(){
angular.module("myApp")
.controller('ProcessController', ['$http', function($http){
this.something = "Test"
}]);
})(); //<-- () function should get called to self execute it.