javascript - Angular 'PersonCtrl' is not a function, got undefined -



javascript - Angular 'PersonCtrl' is not a function, got undefined -

hi trying build first angular app typescript can not seem bind controller correctly.

this typescript code:

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; } interface ipersonctrl { } class personctrl implements ipersonctrl{ public $scope: ipersonscope; static $inject = ['$scope']; constructor($scope: ipersonscope) { this.$scope = $scope; this.init(); } init() : void { this.$scope.fullname = 'justin s.'; } } }

this view code:

<article ng-app> <section ng-controller="personctrl"> <p ng-bind="fullname"></p> </section> </article>

edit after updating html this:

<article ng-app="app"> <section ng-controller="personctrl"> <p ng-bind="fullname"></p> </section> </article>

i started geting next error:

uncaught error: [ng:areq] argument 'fn' not function, got undefined

all related javascript files loaded on page

you need provide application name, root module app or app.person (angular.module('app.person')) value ng-app:

// should root module name <article ng-app="app"> // or app.person // <article ng-app="app.person"> <section ng-controller="personctrl"> <p ng-bind="fullname"></p> </section> </article>

and sure, file definition part of page <script>

javascript angularjs typescript

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -