Javascript AngularJS可以';t插值误差
我在浏览器中遇到此错误:Javascript AngularJS可以';t插值误差,javascript,angularjs,Javascript,Angularjs,我在浏览器中遇到此错误: Error: [$interpolate:interr] Can't interpolate: {{ displayName(stream.StreamName) }} TypeError: undefined is not a function http://errors.angularjs.org/1.2.25/$interpolate/interr?p0=%0A%20%20%20%20%2…0A%20%20%20%20%20%20&p1
Error: [$interpolate:interr] Can't interpolate:
{{ displayName(stream.StreamName) }}
TypeError: undefined is not a function
http://errors.angularjs.org/1.2.25/$interpolate/interr?p0=%0A%20%20%20%20%2…0A%20%20%20%20%20%20&p1=TypeError%3A%20undefined%20is%20not%20a%20function
代码非常简单,下面是HTML:
<div class="card" ng-repeat="stream in streams">
<div class="item item-divider">
{{ displayName(stream.StreamName) }}
</div>
<ion-list>
<div class="item " ng-repeat="(key, value) in stream">
{{key}}
<p>
{{value}}
</p>
</div>
</ion-list>
“无法插入”的措辞让我不知所措:)
当我尝试console.log()时,它无法工作。。。问题是,我拼错了javascriptsubString()
。它没有大写,它的子字符串()
写这个问题和答案的唯一原因是让其他人知道当你得到“插值错误”时,它可能像javascript打字一样简单
angular.module('starter')
.controller('StreamsCtrl', function ($scope, $timeout) {
$scope.displayName = function(s) {
return s.subString(s.lastIndexOf('/')+1)
}
});