Angularjs: Error: [ng:areq] Argument '...' is not a function, got undefined

starting my app with angular 1.5+

here is my controller code

'use strict';

(function(){

class FlamingoController {
    constructor($http) {
        this.$http = $http;
        this.flamingo = [];
    }

    $onInit() {
        this.$http.get('/api/flamingo')
            .then(response => {
                this.flamingo = response.data;
            })
    }
}

angular.module('wildroseApp')
  .component('flamingo', {
    templateUrl: 'app/flamingo/flamingo.html',
    controller: FlamingoController,
  });

})();

when i'm trying to add my controller in view

<div class="container" ng-controller="FlamingoController as ctrl">

i'm getting this

Error: [ng:areq] Argument 'FlamingoController' is not a function, got undefined

Upvotes: 1

Views: 1664

Answers (1)

user3806549
user3806549

Reputation: 1438

You might have forgotten the ng-app or adding the file to the head. Have checked in network, that the controller is loaded in?

I never used as in angular so I would remove it.

Upvotes: 0

Related Questions