AngularJS不能插值误差 [英] AngularJS can't interpolate error

查看:913
本文介绍了AngularJS不能插值误差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误的浏览器:

 错误:[$插值:INTERR]不能插:
        {{显示名(stream.StreamName)}}类型错误:未定义不是一个函数
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

code是pretty简单,这里是HTML:

 <&GT DIV CLASS =一卡通NG-重复=溪流流;
  < D​​IV CLASS =项项除法>
    {{显示名(stream.StreamName)}}
  < / DIV>
  <离子列表>
    < D​​IV CLASS =项NG重复=(键,值)流>
      {{键}}
      &所述p为H.;
        {{值}}
      &所述; / P>
    < / DIV>
  < /离子列表>

这里是JavaScript的控制器code:

  angular.module('启动器')
.controller('StreamsCtrl',函数($范围,$超时){
  $ scope.displayName =功能(S){
    返回s.subString(s.lastIndexOf('/')+ 1)
  }
});


解决方案

不能插值的措辞使我惊呆了:)

当我试图CONSOLE.LOG(),它不会工作...和问题是,我拼错的JavaScript 子()。它不是资本,它的子()

唯一原因写这个问题,并回答让其他人知道,当你得到插值误差,它可以像JavaScript的错字一样简单。

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.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

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)
  }
});

解决方案

"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.

这篇关于AngularJS不能插值误差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆