最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - AngularJS can't interpolate error - Stack Overflow

programmeradmin6浏览0评论

I am getting this error in browser:

Error: [$interpolate:interr] Can't interpolate: 
        {{ displayName(stream.StreamName) }}

TypeError: undefined is not a function
.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

Code is pretty simple, here is the 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>

And here is the Controller javascript code:

angular.module('starter')
.controller('StreamsCtrl', function ($scope, $timeout) {
  $scope.displayName = function(s) {
    return s.subString(s.lastIndexOf('/')+1)
  }
});

I am getting this error in browser:

Error: [$interpolate:interr] Can't interpolate: 
        {{ displayName(stream.StreamName) }}

TypeError: undefined is not a function
http://errors.angularjs/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

Code is pretty simple, here is the 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>

And here is the Controller javascript code:

angular.module('starter')
.controller('StreamsCtrl', function ($scope, $timeout) {
  $scope.displayName = function(s) {
    return s.subString(s.lastIndexOf('/')+1)
  }
});
Share Improve this question asked Dec 30, 2014 at 22:48 NiTiNNiTiN 1,0221 gold badge16 silver badges25 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

"can't interpolate" wording overwhelmed me :)

When I tried to console.log(), it wouldn't work... and problem was, I misspelled javascript subString(). Its not capitalized, its substring().

Only reason to write this question and answer so others know that when you get 'interpolation error', it could be as simple as javascript typo.

发布评论

评论列表(0)

  1. 暂无评论