嘿,我使用 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/