3

I do understand why angular throws this error but i didn't find a solution that solves my case.

When angular encounter with ng-controller attribute, it tries to find injected controller named as the attribute value.

For example for my case: Angular tries to find StreamHelperController in the injected controller list, when it doesn not find it, it throws

"StreamHelperController is not a function"

.

Known Solution: Injecting controller before loading view layer.

Controller:

var app = angular.module('myapp');
 app.controller('StreamHelperController', ['$scope', function ($scope) {}]);

View:

<div ng-controller="StreamHelperController ">

But the problem occurs when i load view before controller class. And this is my case. So how can i manage and solve this problem ?

ENV: Angularjs 1.5.8

Tractatus
  • 118
  • 1
  • 1
  • 9

1 Answers1

0
  1. javascript is synchronous.
  2. controller is the bond|connection between model and view, without it no communication.
    Thus, controller not defined at time will freeze the parsing.Try using promise or some other asynchronous trick or provide more info.