这是 generated javascript完全正在使用plunkr
但它不起作用(点击我的按钮在我当地没有任何作用)
这是代码:
typescript文件:
module canling.controllers {
export interface IMyStoksScope extends ng.IScope {
gridOptions: any;
gridApi: any;
showMe();
}
export class StoksController {
private $scope: IMyStoksScope
constructor($scope: IMyStoksScope) {
this.$scope = $scope
this.$scope.gridOptions = {}
this.$scope.gridOptions.columnDefs = [
{ name: 'id' },
{ name: 'stokAdi' }, {
name: 'view',
cellTemplate: '<button class="btn primary" ng-click="grid.appScope.showMe()">Click Me</button>'
}]
this.$scope.gridOptions.data = [{ id: 1, stokAdi: "one" }, { id: 2, stokAdi: "two" }]
this.$scope.showMe = function () {
alert(1)
}
}
}
StoksController.$inject = ['$scope'];
angular.module("canling").controller('StoksController', StoksController);
}
module canling {
export class Config {
constructor($routeProvider: ng.route.IRouteProvider, $locationProvider: ng.ILocationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when("/stoks", { templateUrl: "/app/views/stoks/stoks.html", controller: "StoksController" })
}
}
Config.$inject = ['$routeProvider', '$locationProvider'];
}
((): void=> {
var app = angular.module("canling", ['ngRoute', 'ui.grid' ]);
app.config(canling.Config);
})()
并且查看是:
<button ng-click="showMe()">view entry</button>
<div id="grid1" ui-grid="gridOptions" class="grid"></div>
顺便提一下, view entry
按钮点击工作。
任何人都知道为什么网格上的click me
对本地没有任何作用?
答案 0 :(得分:0)
问题解决了。差异来自ui-grid-unstable.js
版本。
:
/*! ui-grid - v3.0.0-RC.18-d9b2314 - 2015-01-06
* Copyright (c) 2015 ; License: MIT */
关于plunkr :
/*!
* ui-grid - v3.0.0-rc.21-aa56355 - 2015-05-06
* Copyright (c) 2015 ; License: MIT
*/