当我尝试使用 Moment JS 库根据用户语言显示日期时,出现此错误:
format.replace is not a function
Run Code Online (Sandbox Code Playgroud)
这是代码:
var localeData = moment.localeData();
switch (navigator.language || navigator.userLanguage) {
case 'fr':
localeData = moment.localeData('fr');
break;
}
localeData.longDateFormat('LL');
var dateToDisplay = moment(1459035326000, "x").format(localeData);
Run Code Online (Sandbox Code Playgroud) 我有一个情况,我必须把嵌套ng-repeat,当我试图得到的$id第一个ng-repeat我没有任何问题,但当我试图获得$id第二个ng-repeat(下图中标记为红色)我got undefined.
我的Firebase结构如下
HTML代码和控制器在这里
angular
.module('starter')
.controller('feedController', function($scope, $firebaseRef, $firebaseArray) {
$scope.allRequests = $firebaseArray($firebaseRef.requests);
$scope.allRequests.$loaded(function() {
console.log(arguments);
})
})Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<span ng-repeat="items in allRequests">
<!-- this works fine -->
{{items.$id}}
<div ng-repeat="item in items">
<!-- getting undefined here... -->
{{item.$id}}
</div>
</span>Run Code Online (Sandbox Code Playgroud)
我需要$id第二ng-repeat,任何帮助将不胜感激.