Search code examples
angularjstypescripthawtio

How angular controllers bind with view?


I dont understand how controllers is connecting with views in Hawtio project.

for example, view:

<div ng-controller="Core.AboutController">
  <div class="welcome">
    <div class="about-display" compile="html"></div>
  </div>
</div>

controller declaration:

module Core {
  export function AboutController($scope, $location, jolokia, branding, localStorage) {
    //...
  }
  //...
}

I expected to find something like that:

angular.module('moduleName').controller('Core.AboutController', Core.AboutController);

But found none. How it works?


Solution

  • This works because in the absence of any registration with angular i.e. angular.module('moduleName').controller('Core.AboutController' angular looks at window and tries to resolve it. Which is what

    module Core {
      export function AboutController
    

    does. After this line window.Core.AboutController will point to the correct function and that is what angular just found.