javascript - 使用 Ionic + TypeScript + Angular 的混合应用程序

标签 javascript angularjs node.js typescript

嘿,我使用 Ionic + Typescript + Angular 开发了混合应用程序。 我使用了 Ionic lib 的 beta 版本,它运行良好,但是当我将 ionic lib beta 版本更新到 1.0.0 版本时,我从 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);
          };
    }
}

我已经用 Typescript 编写了 Controller ,并将其编译为 js,然后在我的应用程序中使用。

App.js

在 app.js 中,我注入(inject) Controller ,如下所示:

angular.module('starter', ['starter.controllers', 'ionic')

最佳答案

我的问题得到了解决-

模块演示{ 导出类 AppCtrl {

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

//your stuff

}

} }

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

关于javascript - 使用 Ionic + TypeScript + Angular 的混合应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30614734/

相关文章:

javascript - 用于开发和生产构建的 Webpack Angular 应用程序 API URL 配置

javascript - AngularJS 中的复选框不会触发 onChange 事件

javascript - require() 实际返回什么,文件或函数

javascript - Bootstrap : Access radio buttons using tab press

javascript - 我收到错误 : Can't perform a React state update on an unmounted component even though i created cleanup

javascript - 如何发送 JSON 数据而不是将其记录到控制台

javascript - nodeclipse 中每个外部 java 脚本文件都出现错误

javascript - 停止 jQuery draggable 从屏幕上滚动

javascript - flow.js 点击上传文件

javascript - 使用 Angular 值绘制动态变化的谷歌图表