![](/img/trans.png)
[英]AngularJs: Error: [ng:areq] Argument 'fn' is not a function, got undefined
[英]Uncaught Error: [ng:areq] Argument 'fn' is not a function, got undefined
嗨,我正在嘗試使用Typescript構建我的第一個Angular應用程序,但我似乎無法正確綁定控制器。
這是我的打字稿代碼:
module App {
var modules: string[] = ["App.Person"];
angular.module('App', modules)
.run([]);
}
module App.Person {
angular.module('App.Person', []);
}
module App.Person {
angular.module("App.Person")
.controller('PersonCtrl', PersonCtrl);
interface IPersonScope extends ng.IScope {
fullName: string;
}
class PersonCtrl{
public $scope: IPersonScope;
static $inject = ['$scope'];
constructor($scope: IPersonScope) {
this.$scope = $scope;
this.init();
}
init() : void {
this.$scope.fullName = 'Justin S.';
}
}
}
這是我的看法:
<article ng-app="App">
<section ng-controller="PersonCtrl">
<p ng-bind="fullName"></p>
</section>
</article>
我收到以下錯誤:
Uncaught Error: [ng:areq] Argument 'fn' is not a function, got undefined
我該如何解決這個問題?
很可能您可能錯過了在布局頁面中包含控制器js文件(例如: <script src='path/angularController.js'></script>
)。 如果沒問題,那么請仔細檢查你的html中是否有多個ng-app。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.