简体   繁体   中英

How to pass value in angular 2 selector using variable?

I want to pass value to selector of angular like below. What is different in this question is that I am passing the variables to selector properties of child component.

              <app-jform 
                  [modulename]="'({{modulename}})'"
                  [tabpgrpid]="'({{tabpgrpid}})'"
                   [tabgrpname]="'({{tabgrpname}})'"
                 [usertabgrpname]="'({{usertabgrpname}})'"
                  [moduleid]="'({{moduleid}})'"
                [templateid]="'({{templateid}})'">
             </app-jform> 

here modulename, tabgrpid, tabgrpname etc. are variables defined and assigned in component. I am getting the following error while doing this.

                 Parser Error: Got interpolation ({{}}) where expression was 
                 expected at column 1 in ['{{modulename}}'] in 
               ng:///AppModule/ViewBaseComponent.html@65:3 ("

                   <app-jform 
            [ERROR ->][modulename]="'{{modulename}}'"
           [tabpgrpid]="'{{tabpgrpid}}'"
          [tabgrpname]="'{{tabgrpname}}'"
            "): ng:///AppModule/ViewBaseComponent.html@65:3

how to pass this variables to properties of selector?

Just pass without the annotation

<app-jform  [modulename]="modulename"
            [tabpgrpid]="tabpgrpid"
            [tabgrpname]="tabgrpname"
            [usertabgrpname]="usertabgrpname"
            [moduleid]="moduleid"
            [templateid]="templateid">
 </app-jform> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM