0
我需要使用angular.js從視圖中調用類型腳本中的函數。我使用的技術是angular.js打字稿和ASP.Net MVC3。ng-click不觸發Angularjs
這是用戶界面中的鏈接。
<div id="left_aside" ng-controller="MyGivingPortfolioController">
<div class="charity_portfolio_tile" ng-repeat="Tile in VM.Tiles.TileContainerEntity" >
<a href="#" ng-click="Delete(Tile.Id)" class="delete_button">delete</a>
</div>
當我點擊這個鏈接它不調用該方法。
Delete = function (Id:number) {
alert("Called " + Id.toString());
}
然後我改變了這個功能,如下所示。
Delete(charityID: number) {
var id = charityID;
alert(id.toString());
}
雖然我改變了代碼,但沒有奏效。其實我不知道這個原因。
class MyController implements IMyController {
Tiles: TileContainerEntities;
constructor($scope, $http: ng.IHttpService) {
$scope.VM = this;
$http.get("/API/PrivateAPI/Test/1").success((responce) =>{this.BusinessReponseList = responce; });
}
Delete = function (Id:number) {
alert("Called " + Id);
}
//Delete(charityID: number) {
// var id = charityID;
// alert(id.toString());
//}
}
有誰知道怎麼做?
你能分享你的控制器代碼! –
它應該是'VM.Delete'。看到我的回答 – basarat