Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

Hey I had developed hybrid app using Ionic + Typescript + Angular. I used beta version of Ionic lib, it was running fine, but when i update my ionic lib beta version to 1.0.0 version, then i got following error from ionic.bundle.js

Error: [ng:areq] Argument 'AppCtrl' is not a function, got undefined http://errors.angularjs.org/1.3.13/ng/areq?p0=AppCtrl&p1=not%20a%20function%2C%20got%20undefined minErr/<@file:///E:/Yogesh/my_task/myApp/www/lib/ionic/js/ionic.bundle.js:8763:12 assertArg@file:///E:/Yogesh/my_task/myApp/www/lib/ionic/js/ionic.bundle.js:10280:1 assertArgFn@file:///E:/Yogesh/my_task/myApp/www/lib/ionic/js/ionic.bundle.js:10290:1 $ControllerProvider/this.$get

AppCtrl.ts

angular.module('starter.controllers',[]);

class AppCtrl{

    constructor($scope, $ionicModal, $timeout)
    {
         // Form data for the login modal
          $scope.loginData = {};

          // Create the login modal that we will use later
          $ionicModal.fromTemplateUrl('templates/login.html', {
            scope: $scope
          }).then(function(modal) {
            $scope.modal = modal;
          });

          // Triggered in the login modal to close it
          $scope.closeLogin = function() {
            $scope.modal.hide();
          };

          // Open the login modal
          $scope.login = function() {
            $scope.modal.show();
          };

          // Perform the login action when the user submits the login form
          $scope.doLogin = function() {
            console.log('Doing login', $scope.loginData);
            $timeout(function() {
              $scope.closeLogin();
            }, 1000);
          };
    }
}

I have written my controller in Typescript and after compile it in to js and then used in my app.

App.js

in app.js i inject my controller like following:

angular.module('starter', ['starter.controllers', 'ionic')
share|improve this question
    
Try to add export modifier to class declaration typescriptlang.org/Handbook#modules-export- – Mikalai Jun 3 at 8:33
    
If i used export then also i got error – Yogesh Srivastav Jun 3 at 9:30
    
module starter.controllers { export class AppCtrl { constructor($scope, $ionicModal, $timeout) { } } – Yogesh Srivastav Jun 3 at 9:31
    
Try to move declaration of class before declaration of controller angular.module('starter.controllers').controller('AppCtrl', AppCtrl) – Mikalai Jun 3 at 10:10

I got solution for my problem-

module DemoNS { export class AppCtrl {

constructor($scope, $ionicModal, $timeout) {

//your stuff

}

} }

angular.module('starter.controllers',[]).controller("AppCtrl", ["$scope","$ionicModal","$timeout", DemoNS.AppCtrl]);

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.