解析器错误:在需要表达式的地方进行了插值({{}}) [英] Parser Error: Got interpolation ({{}}) where expression was expected

查看:259
本文介绍了解析器错误:在需要表达式的地方进行了插值({{}})的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ng-bootstrap替代angular2中的ui-bootstrap.

I'm using ng-bootstrap as a substitute for ui-bootstrap in angular2.

我的html如下:

<ul class="list-inline">
    <li class="tag" ngb-dropdown auto-close="outsideClick" 
        *ngFor="let item of ['Elastic Search','Database Theory','CVS'];
        let $index=index;" 
        [ngClass]="{'default-tag': $index==0, 'matched-tag': $index==1, 'unmatched-tag': $index==2 }">
         <a href ngb-dropdown-toggle id="desiredSkill{{$index}}">
             <i class="bi_interface-tick following"></i> {{item}} <i class="bi_interface-more tag-menu-icon"></i>
                            </a>
               <ul class="dropdown-menu tag-menu" ngb-dropdown-menu [aria-labelledby]="desiredSkill{{$index}}">
                     <li><a href>Follow Skill</a></li>
                     <li><a href>Related Jobs</a></li>
                </ul>
     </li>
  </ul>

但是当我运行我的应用程序时,出现以下错误:

But when I run my app I get following error:

main.browser.ts:25错误:模板解析错误: 解析器错误:进行了插值({{}}),其中期望在[desiredSkill {{$ index}}]中的第12列显示表达式 JobDescription @ 174:77( ] [aria-labelledby] ="desiredSkill {{$ index}}">

  • "):JobDescription @ 174:77 解析器错误:JobDescription @ 174:77([
    ] [aria-labelledby] ="desiredSkill {{$ index}}">
  • "):JobDescription @ 174:77 无法绑定到"aria-labeledby",因为它不是"ul"的已知属性. ( ] [aria-labelledby] ="desiredSkill {{$ index}}">
  • "):JobDescription @ 174:77 解析器错误:进行了插值({{}}),其中期望在[desiredSkill {{$ index}}]中的第12列显示表达式 JobDescription @ 174:77("
  • main.browser.ts:25Error: Template parse errors: Parser Error: Got interpolation ({{}}) where expression was expected at column 12 in [desiredSkill{{$index}}] in JobDescription@174:77 (" ][aria-labelledby]="desiredSkill{{$index}}">

  • "): JobDescription@174:77 Parser Error: Unexpected token '{' at column 13 in [desiredSkill{{$index}}] in JobDescription@174:77 ("
    ][aria-labelledby]="desiredSkill{{$index}}">
  • "): JobDescription@174:77 Can't bind to 'aria-labelledby' since it isn't a known property of 'ul'. (" ][aria-labelledby]="desiredSkill{{$index}}">
  • "): JobDescription@174:77 Parser Error: Got interpolation ({{}}) where expression was expected at column 12 in [desiredSkill{{$index}}] in JobDescription@174:77 ("
  •                 <div class="row">
                      <div class="col-lg-4 col-xs-4" [ERROR ->]*ngFor="let i of [0,1,3]">
                        <img src="http://ecx.images-amazon.com/images/I/81VFU9"):
    

    工作描述@ 215:49 解析器错误:JobDescription @ 174:77("

    JobDescription@215:49 Parser Error: Unexpected token '{' at column 13 in [desiredSkill{{$index}}] in JobDescription@174:77 ("

                    <div class="row">
                      <div class="col-lg-4 col-xs-4" [ERROR ->]*ngFor="let i of [0,1,3]">
                        <img src="http://ecx.images-amazon.com/images/I/81VFU9"):
    

    工作描述@ 215:49 解析器错误:进行了插值({{}}),其中期望在[desiredSkill {{$ index}}]中的第12列显示表达式 JobDescription @ 174:77( ERROR-> ="main.applyJob()">申请工作 ERROR-> ="main.applyJob()">申请工作 ] [hidden] =!ifNotApplied">已应用 ] [hidden] =!ifNotApplied">已应用 ] [hidden] =!ifNotUploaded">上传简历 ] [hidden] =!ifNotUploaded">上传简历 对这项工作有疑问吗?

    JobDescription@215:49 Parser Error: Got interpolation ({{}}) where expression was expected at column 12 in [desiredSkill{{$index}}] in JobDescription@174:77 (" ERROR ->="main.applyJob()">Apply for job ERROR ->="main.applyJob()">Apply for job ][hidden]="!ifNotApplied">Applied ][hidden]="!ifNotApplied">Applied ][hidden]="!ifNotUploaded">Upload CV ][hidden]="!ifNotUploaded">Upload CV Have questions about this job?

    推荐答案

    您不能在standart属性绑定中使用插值.应该有表情.

    You can't use interpolation inside standart property binding. There should be expression.

    似乎应该是:

    [attr.aria-labelledby]="'desiredSkill' + $index"
    

    attr.aria-labelledby="desiredSkill{{$index}}"
    

    这篇关于解析器错误:在需要表达式的地方进行了插值({{}})的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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