When you assign a name to the ng-app directive, you essentially create a module with that name. In this module you will need to define your directives, services, filters and configurations.
In your case, when you assigned the name "demo", you created a module named "demo". The DemoController function DemoController now no longer part of this module.
To use this function AND assign a module to your application, you need to use the following method for defining a controller:
var app = angular.module("demo", []); app.controller('DemoController', [function () {
Thus, the application knows which module controller needs to be bound for the corresponding view area.
EDIT: Link to ng-app directive
source share