javascript - Simple ng-click not working in typescript -


i'm trying call function in click function html page , added typescript definition files nuget going wrong click function not working .... no error in console even

here hrml , controller code

html page

<!doctype html> <html xmlns="http://www.w3.org/1999/xhtml">   <head>     <script src="scripts/angular.js"></script>      <script src="test.js"></script>     <title></title>  </head> <body ng-app="testmodule">     <div ng-controller="test">         <input type="button" ng-click="click()" value="test" />     </div> </body> </html> 

controller

angular.module("testmodule", []);  class test {      constructor() { }      click() {          alert();     } }    angular.module("testmodule").controller("test", test ); 

this not work because ng-click="click()" tries call $scope.click() not defined.

i highly advise use controller as-syntax when working angularjs , typescript

demo


Comments