I'm getting crazy about how AngularJS + Typescript work together. Basically what I want to achieve is a simple call to a method. The problem is that I have to use a certain kind of "architecture" and I don't know where I made the mistake.
this is my interface (IAthorizathionScope.ts):
module Main { export interface IAuthorizationScope extends ng.IScope { vm: AuthenticationController; login: (username: string, password: string) => void; } }
this is my controller (AuthorizationController.ts):
module Main { 'use strict'; export class AuthenticationController { public static $inject = [ '$scope', ]; private username: string; private password: string; constructor($scope : IAuthorizationScope) { $scope.vm = this; } login = function (username:string, password:string) { alert("authorised!"); } } }
and this is my view (secretTest.html):
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div ng-controller="AuthenticationController">
<label>Username: <input type="text" ng-model="username"/> </label>
<label>Password: <input type="password" ng-model="password"/> </label>
<button ng-click="vm.login(username, password)">
Login
</button>
</div>
</body>
</html>
EDIT This is my application file (Application.js)
module Main { 'use strict'; var txtmobileMvc = angular.module('txtmobileMvc', ['kendo.directives']) // factories .factory('Main.ItemCommonModel', function ($rootScope) { return new Main.ItemCommonModel($rootScope); }) // controllers .controller('detailCollectionController', DetailCollectionController) .controller('detailController', DetailController) .controller('gridController', GridController) .controller('authenticationController', AuthenticationController) .controller('wijmoController', WijmoController) // services .service('itemStorage', ItemStorage) .service('itemDataService', ItemDataService) // Page routing .config(($routeProvider: ng.IRouteProvider) => { $routeProvider .when('/', { controller: 'detailController', templateUrl: 'views/detail.html' }) .when('/grid', { controller: 'gridController', templateUrl: 'views/grid.html' }) .when('/secret', { controller: AuthenticationController, templateUrl: 'views/secretTest.html'}) .when('/wijmo', { controller: WijmoController, templateUrl: 'views/wijmoTest.html' }) .otherwise({ redirectTo: '/' }); }); }
Probably I'm also confused about how this stuff works here. Thank you in advance.
body
like<body ng-app>
– Satpal