我对Angular相当陌生,并且一个简单的绑定对我不起作用。AngularJS绑定似乎不起作用
它只是显示我和{{trip.created}}
正如他们写的。
我的控制器:
(function() {
"use strict";
angular.module("app-trips")
.controller("tripsController", tripsController);
function tripsController() {
var vm = this;
vm.trips = [{
name: "US Trip",
created: new Date()
}, {
name: "World Trip",
created = new Date()
}];
我的课的一部分:
@section Scripts {
<script src="~/lib/angular/angular.min.js"></script>
<script src="~/js/app-trips.js"></script>
<script src="~/js/tripsController.js"></script>
}
<div class="row" ng-app="app-trips">
<div ng-controller="tripsController as vm" class="col-md-6 col-md-offset-3">
<table class="table table-responsive table-striped">
<tr ng-repeat="trip in vm.trips">
<td>{{ trip.name }}</td>
<td>{{ trip.created }}</td>
</tr>
</table>
</div>
控制器的看法:
(function() {
"use strict";
angular.module("app-trips", ['ngSanitize']);
})();
BTW - 按说根据我的过程以下,我不需要['ngSanitize']
,但没有它,它甚至不显示DIV
s。
编辑:作为@jellyraptor注意到,我曾与=,而不是一个错字:
编辑2:
这是错字+的[ngSanitize
]我真的没有需要。我修正了错字,并传递了一个空数组,一切正常。谢谢全部
这是一个猜测。基于它没有'['ngSanitize']'不起作用的事实,似乎你从未真正创建过角度模块。当您向'angular.module(moduleName,[数组相关性])提供第二个(数组)参数时,会创建该模块。如果没有这个数组,角度将表达式视为一个getter而不是一个setter。 – ryanyuyu