0
我忙于尝试学习Angular + Typescript + bootstrap,我偶然发现了一个我无法解决的问题。我有一个NG-重复在一个局部视图:只能在IE中工作的ng-repeat
<div>
<h1>Debtors</h1>
<table class="table table-hover">
<thead>
<tr>
<th>Debtor</th>
<th class="col-sm-1"></th>
<th class="col-sm-1"></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="Debtor in vm.Debtors">
<td>{{Debtor.Name}}</td>
<td><a href="" ng-click="vm.EditDebtor(Debtor.ID)"><i class="fa fa-pencil fa-fw fa-lg"></i> Edit</a></td>
<td><i class="fa fa-trash-o fa-fw fa-lg"></i> Delete</td>
</tr>
</tbody>
</table>
与控制器:
module Controllers
{
export class DebtorsController
{
static $inject = ['$scope', '$http', '$modal'];
Debtors: Models.TradePartyModel[];
ModalService: ng.ui.bootstrap.IModalService;
constructor($scope: ng.IScope, $http: ng.IHttpService, $modal: ng.ui.bootstrap.IModalService)
{
this.ModalService = $modal;
$http.get("http://localhost:51263/api/debtors/1")
.success((Debtors) =>
{
this.Debtors = Debtors;
});
}
}
}
路由定义为:
$routeProvider.when('/Debtors/ViewDebtors', {
templateUrl: 'App/Views/Debtors/Debtors.html',
controller: Controllers.DebtorsController,
controllerAs: "vm"
});
这工作完全正常在IE中,它会显示表格和所有数据,但在FireFox或Chrome中似乎不起作用。我检查过提琴手,数据恢复正常,但表格没有显示。
任何想法?谢谢!
任何控制台错误?您是否安装了Chrome Angular扩展程序以在Debtors返回后验证范围? – Scott
在Firefox控制台中没有错误,chrome给出了这个错误:GET http:// localhost:51263/api/debtors/1 angular.js:7889 (匿名函数)angular.js:7889 sendReq angular.js: 7720 $ http.serverRequest angular.js:7454个 wrappedCallback angular.js:10655个 wrappedCallback angular.js:10655 (匿名函数)angular.js:10741 范围$ EVAL angular.js:11634 范围$消化angular.js:11479 $代表.__原__ $消化VM48:844 范围$适用angular.js:。11740 $代表.__原__ $适用VM48:855 (匿名函数)angular.js:8950 jQuery的。 event.dispatch jquery-1。 9.1.js:3074 elemData.handle – user1435899
不完全确定角度扩展是如何工作的,但它在根作用域下提供了三个作用域,一个根作用域和两个兄弟作用域。第二个范围说:这个范围没有模型,第三个范围有:vm:{ModalService:{...}} – user1435899