[英]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.