對於myLongString
,我想通過對其進行過濾鏈式功能
(1)保持第一y
字符和(2)把它的所有小寫
HTML
<body ng-controller="MyCtrl">
<span>{{myLongString | limitTo:5 | lowercase}}</span>
</body>
的JavaScript
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.myLongString = "EEEEEEEEEEEE";
$scope.limitTo = function(x, y) {
console.log("x:", x, "y:", y);
x.slice(0, y);
}
$scope.lowercase = function() {
$scope.myLongString = $scope.myLongString.toLowerCase();
}
}
文本全部是小寫,但我沒有看到前5個字符切片。另外,console.log
不顯示。
這是爲什麼?