Why a controller does not work in separated files?
Application structure:
store.html:
<!DOCTYPE html> <html lang="en" ng-app="myApp"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script> </head> <body> <div ng-controller="userController"> <h1>{{user.firstname}}</h1> </div> <script src="/static/app/user/userController.js"></script> <script src="/static/app/app.js"></script> </body> </html> app.js:
var app = angular.module("myApp",[]); app.controller("myContoller",["$scope",function ($scope) { }]); userController.js
app.controller("userController",["$scope",function ($scope) { $scope.hello= "john doe"; $scope.user = { id:1, firstname:"Wojciech" } }]);