APIを使用してコメント(絵文字付き)を読み込む際に問題が発生します。AngularJSアプリで「limitTo」フィルタを使用すると、ダイヤモンドの形の疑問符文字が表示される
<!doctype html>
<html ng-app="app">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="./angular-1.2.15.js"></script>
<!-- ... -->
</head>
<body>
<!-- ... -->
<ul>
<li ng-repeat="comment in comments">
<span ng-bind="comment.Author"></span>
<span ng-bind="comment.Description"></span>
</li>
</ul>
<!-- ... -->
<script>
angular.module('app', []);
// ...
</script>
</body>
</html>
予想通りlimitTo
フィルタすべてが行く前に:
<span>John Doe</span>
<span>Hey, how are you? ☺</span>
しかし、私はlimitTo
フィルタを適用しようとすると、何かがうまくいかない:
<span>John Doe</span>
<span>Hey, how are you? �</span>
私が間違って何をしているのですか?何か案は?
var app = angular.module('myApp', []);
app.filter('range', function() {
return function(input, total) {
total = parseInt(total);
for (var i=0; i<total; i++) {
input.push(i);
}
return input;
};
});
app.controller('DemoController', ['$scope', function ($scope) {
$scope.comment = {
Author: "John Doe",
Description: "Hey, how are you? ☺"
};
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
<div ng-app="myApp">
<div ng-controller="DemoController">
<ul>
<li ng-repeat="i in [] | range:78" ng-init="limit = 20+i">
<div ng-bind="comment.Author"></div>
<span ng-bind="comment.Description | limitTo: limit"></span> (<span ng-bind="limit"></span>)
</li>
</ul>
</div>
</div>
これはなんですか? o_O –