我为智能表创建了一个带有Typescript angular的自定义指令。但是当我对列表进行排序时,数据正在消失...当我只用角度js写相同时。它工作正常。
你能帮助我做错了吗...
网格HTML
<table st-safe-src="rowCollection" st-table="gridOptions" class="table table-condensed table-hover">
<thead>
<tr>
<th st-sort="type">Type</th>
<th st-sort="name">Name</th>
<th st-sort="address">Address</th>
<th ng-if="city">City/State</th>
<th ng-if="zip">Zip</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in options">
<td width="20%">{{row.type | uppercase}}</td>
<td width="20%">{{row.name | uppercase}}</td>
<td width="30%">{{row.address | uppercase}}</td>
<td width="15%" ng-if="city">{{row.cityState | uppercase}}</td>
<td width="15%" ng-if="zip">{{row.zip | uppercase}}</td>
</tr>
</tbody>
</table>
打字稿控制器
/// <reference path="../../typings/app.d.ts" />
namespace app.widgets {
'use strict';
interface IGridAttributes extends ng.IAttributes {
cityVisible: string;
zipVisible: string;
options: string;
}
export class updGridCtrl {
static $inject: Array<string> = ['$scope', '$filter'];
constructor(private scope: ng.IFormController) {
this.activate();
}
gridOptions: any = null;
city: boolean;
zip: boolean;
activate() {}
}
class LtcgUpdGridDirective implements ng.IDirective {
static instance(): ng.IDirective { return new LtcgUpdGridDirective(); }
restrict: string = 'E';
transclude = true;
scope = {
'cityVisible': "@",
'zipVisble': "@",
'options': '='
};
templateUrl = 'views/widgets/ltcg-updgrid.html';
link = (scope: any, element: ng.IAugmentedJQuery, attrs: IGridAttributes, ctrl: any) => {
scope.gridOptions = scope.options //private scoped from options : '=',
scope.city = true;
scope.zip = true;
console.log(scope.zipVisible);
if (attrs.cityVisible == "no") {
scope.city = false;
}
if (attrs.zipVisible == "no") {
scope.zip = false;
}
}
}
angular
.module('app.widgets')
.directive('ltcgUpdGrid', LtcgUpdGridDirective.instance);
}