【问题标题】:Angular TypeError: name.replace is not a function for bs-popoverAngular TypeError:name.replace 不是 bs-popover 的函数
【发布时间】:2017-02-17 20:46:53
【问题描述】:

我是 Angular 新手,在控制台 TypeError 中不断收到以下错误:name.replace is not a function。我不确定到底是什么原因造成的,但它似乎是由 bs-popover 引起的,也许与 snake_case 有关?

我不明白的部分是为什么如果使用 bs-popover 会引发在文本框中使用 popover 的错误,但应用程序的其余部分运行良好并且不会引发错误。

有谁知道此错误消息的原因和可能的修复方法?

HTML:

<input class="form-control" ng-model="chequeValue.BankName" name="BankName" 
ng-required='true'  data-toggle="tooltip" data-placement="top" title=" {{chequeValue.BankName}}" data-unique="1" data-auto-close="1" data-placement="top" data-content-template="popover-tmpl.html" data-title="Name" data-html="true" bs-popover>

【问题讨论】:

  • TypeError: name.replace is not a function. I'm not sure what's exactly causing it 你正在尝试运行.replace,它不是一个函数。 bs-popover 是什么?
  • 此错误来自您的 javascript,请发布您的代码。

标签: html angularjs angular-ui-bootstrap popover


【解决方案1】:

角度表达式中不能有空格

title=" {{chequeValue.BankName}}"

我不确定这是否是问题所在。进一步查看文档并更新到 uib-popover

https://angular-ui.github.io/bootstrap/#popover

【讨论】:

    【解决方案2】:

    我找到了我的问题的答案。最好使用 ui-bootstrap 中的 bootstrap popover,而不是使用 angular-strap 进行 popover。

    <input class="form-control" ng-model="chequeValue.BankName" popover='{{chequeValue.BankName}}' data-placement="top" title=" {{chequeValue.BankName}}" popover-trigger="focus" popover-auto-close="outsideClick" popover-placement="top" popover-title="Drawee Bank Name">
    

    【讨论】:

      猜你喜欢
      • 2012-05-03
      • 1970-01-01
      • 2015-07-06
      • 1970-01-01
      • 2017-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多