使用 Angular 1.5+ 启动我的应用程序
这是我的 Controller 代码
'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,
});
})();
当我尝试在 View 中添加 Controller 时
<div class="container" ng-controller="FlamingoController as ctrl">
我明白了
Error: [ng:areq] Argument 'FlamingoController' is not a function, got undefined
最佳答案
您可能忘记了 ng-app 或将文件添加到头部。已检查网络, Controller 已加载?
我从未在 Angular 中使用过 as,所以我将删除它。
关于javascript - Angularjs:错误:[ng:areq]参数 '...'不是函数,未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38291005/