简体   繁体   English

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

[英]hybrid app using Ionic + TypeScript + Angular

Hey I had developed hybrid app using Ionic + Typescript + Angular. 嘿,我已经使用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 我使用了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 错误:[ng:areq]参数'AppCtrl'不是函数,未定义http://errors.angularjs.org/1.3.13/ng/areq?p0=AppCtrl&p1=not%20a%20function%2C%20got% 20未定义的 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 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. 我已经用Typescript编写了控制器,然后将其编译为js,然后在我的应用中使用。

App.js App.js

in app.js i inject my controller like following: 在app.js中,我将控制器注入如下:

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

I got solution for my problem- 我为我的问题找到了解决方案-

module DemoNS { export class AppCtrl { 模块DemoNS {导出类AppCtrl {

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

//your stuff

}

} } }}

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

just make a reference to your controller in the angular way as follows and you're good to go :-) 只需按如下方式以角度方式引用您的控制器,就可以了:-)

 angular.module('starter.controllers') .controller('AppCtrl', AppCtrl); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 离子/角度混合应用程序,无法正常运行震动事件 - Ionic / Angular hybrid app, issue with getting a shake event working IOAuth.IO与Ionic / Angular混合应用程序集成 - IOAuth.IO Integration with Ionic/Angular Hybrid App 将JavaScript \\ Ionic \\ Angular 1应用程序迁移到Typescript \\ Ionic 2 \\ Angular 2应用程序 - Migrating a JavaScript\Ionic\Angular 1 App to Typescript\Ionic 2\Angular 2 App 使用downgradeComponent时,无法加载Bootstrapped Angular 2 + Angular 1 Hybrid App - Bootstrapped Angular 2 + Angular 1 Hybrid App not loading when using downgradeComponent 如何在 Ionic/Angular 混合应用程序中使用cordova inappbrowser 打开链接 - How do I use cordova inappbrowser to open links in Ionic/Angular hybrid app 使用带路由的ngUpgrade引导Angular 2 rc.6混合应用程序 - Bootstrapping an Angular 2 rc.6 hybrid app using ngUpgrade with routing 带有Ionic 2 Angular 2和TypeScript的OpenPGP - OpenPGP with Ionic 2 Angular 2 and TypeScript 在Android而非iOS上使用离子崩溃构建的混合应用程序 - hybrid app built with ionic crashes on android but not ios 离子混合移动应用程序获取设备位置 - Ionic hybrid mobile app get device location 在android上获取混合应用程序(离子)的日志 - getting log for hybrid app(ionic) on android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM