Angular 7 issue with passing value to components htmlAngular HTML bindingWhat does “… resolves to a non-module entity and cannot be imported using this construct” mean?how to import highcharts offline-exporting in typescriptHow to use feathers-client and superagent in Angular 2?Error with combining Array types? Error: Cannot invoke an expression whose type lacks a call signatureCannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signaturesCannot invoke an expression whose type lacks a call signature, mapCannot invoke an expression whose type lacks a call signature … has no compatible call signaturesHow to use delay with HTTPClient Rxjs 6.3.0Property trigger does not exist on type data:String Jquery in Angular ts file

Is there a problem with hiding "forgot password" until it's needed?

Would this custom Sorcerer variant that can only learn any verbal-component-only spell be unbalanced?

Increase performance creating Mandelbrot set in python

How does buying out courses with grant money work?

Flow chart document symbol

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

How to run a prison with the smallest amount of guards?

Is exact Kanji stroke length important?

A Rare Riley Riddle

How do I find the solutions of the following equation?

Crossing the line between justified force and brutality

Roman Numeral Treatment of Suspensions

How do scammers retract money, while you can’t?

Is it appropriate to ask a job candidate if we can record their interview?

How did Arya survive the stabbing?

What is paid subscription needed for in Mortal Kombat 11?

How to write papers efficiently when English isn't my first language?

Return the Closest Prime Number

How can I kill an app using Terminal?

Is expanding the research of a group into machine learning as a PhD student risky?

Large drywall patch supports

What is the difference between "behavior" and "behaviour"?

How do I rename a Linux host without needing to reboot for the rename to take effect?

Go Pregnant or Go Home



Angular 7 issue with passing value to components html


Angular HTML bindingWhat does “… resolves to a non-module entity and cannot be imported using this construct” mean?how to import highcharts offline-exporting in typescriptHow to use feathers-client and superagent in Angular 2?Error with combining Array types? Error: Cannot invoke an expression whose type lacks a call signatureCannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signaturesCannot invoke an expression whose type lacks a call signature, mapCannot invoke an expression whose type lacks a call signature … has no compatible call signaturesHow to use delay with HTTPClient Rxjs 6.3.0Property trigger does not exist on type data:String Jquery in Angular ts file













-3















I am trying something very simple but I keep getting an error:



Here is the code:



app.component.html



<div class="col-md-myvalue">stuff here</div>


app.component.ts



myvalue: string;


ngOnInit()
this.myvalue('6');



For some reason it's giving me this error:



Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.



What I'm I doing wrong here?










share|improve this question

















  • 2





    You can't call a string, it's not a function. this.myvalue = '6';

    – ritaj
    Mar 8 at 11:31






  • 1





    you also should use [ngClass]='"

    – Yanis-git
    Mar 8 at 11:33






  • 1





    Angular is not Knockout! :D

    – Jamie Rees
    Mar 8 at 11:36











  • did you define myvalue a function? obviously not try to assign value rather than passing as a param. you can use ng-class for this

    – Muhammad Farrukh Faizy
    Mar 8 at 11:41















-3















I am trying something very simple but I keep getting an error:



Here is the code:



app.component.html



<div class="col-md-myvalue">stuff here</div>


app.component.ts



myvalue: string;


ngOnInit()
this.myvalue('6');



For some reason it's giving me this error:



Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.



What I'm I doing wrong here?










share|improve this question

















  • 2





    You can't call a string, it's not a function. this.myvalue = '6';

    – ritaj
    Mar 8 at 11:31






  • 1





    you also should use [ngClass]='"

    – Yanis-git
    Mar 8 at 11:33






  • 1





    Angular is not Knockout! :D

    – Jamie Rees
    Mar 8 at 11:36











  • did you define myvalue a function? obviously not try to assign value rather than passing as a param. you can use ng-class for this

    – Muhammad Farrukh Faizy
    Mar 8 at 11:41













-3












-3








-3








I am trying something very simple but I keep getting an error:



Here is the code:



app.component.html



<div class="col-md-myvalue">stuff here</div>


app.component.ts



myvalue: string;


ngOnInit()
this.myvalue('6');



For some reason it's giving me this error:



Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.



What I'm I doing wrong here?










share|improve this question














I am trying something very simple but I keep getting an error:



Here is the code:



app.component.html



<div class="col-md-myvalue">stuff here</div>


app.component.ts



myvalue: string;


ngOnInit()
this.myvalue('6');



For some reason it's giving me this error:



Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures.



What I'm I doing wrong here?







angular typescript angular7






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 11:30









Paul B2001Paul B2001

43




43







  • 2





    You can't call a string, it's not a function. this.myvalue = '6';

    – ritaj
    Mar 8 at 11:31






  • 1





    you also should use [ngClass]='"

    – Yanis-git
    Mar 8 at 11:33






  • 1





    Angular is not Knockout! :D

    – Jamie Rees
    Mar 8 at 11:36











  • did you define myvalue a function? obviously not try to assign value rather than passing as a param. you can use ng-class for this

    – Muhammad Farrukh Faizy
    Mar 8 at 11:41












  • 2





    You can't call a string, it's not a function. this.myvalue = '6';

    – ritaj
    Mar 8 at 11:31






  • 1





    you also should use [ngClass]='"

    – Yanis-git
    Mar 8 at 11:33






  • 1





    Angular is not Knockout! :D

    – Jamie Rees
    Mar 8 at 11:36











  • did you define myvalue a function? obviously not try to assign value rather than passing as a param. you can use ng-class for this

    – Muhammad Farrukh Faizy
    Mar 8 at 11:41







2




2





You can't call a string, it's not a function. this.myvalue = '6';

– ritaj
Mar 8 at 11:31





You can't call a string, it's not a function. this.myvalue = '6';

– ritaj
Mar 8 at 11:31




1




1





you also should use [ngClass]='"

– Yanis-git
Mar 8 at 11:33





you also should use [ngClass]='"

– Yanis-git
Mar 8 at 11:33




1




1





Angular is not Knockout! :D

– Jamie Rees
Mar 8 at 11:36





Angular is not Knockout! :D

– Jamie Rees
Mar 8 at 11:36













did you define myvalue a function? obviously not try to assign value rather than passing as a param. you can use ng-class for this

– Muhammad Farrukh Faizy
Mar 8 at 11:41





did you define myvalue a function? obviously not try to assign value rather than passing as a param. you can use ng-class for this

– Muhammad Farrukh Faizy
Mar 8 at 11:41












3 Answers
3






active

oldest

votes


















0














Try this,



app.component.html



<div [ngClass]="myvalue">...</div>


app.component.ts



myvalue: string;
ngOnInit()
this.myvalue = 'col-md-'+'6'; //concatenate your value as string here



If you want to pass data using with function, you can achieve it by using this approach,



myvalue: string;
ngOnInit()
this.setValue('6');


setValue(val: string)
this.myvalue = 'col-md-'+val; //concatenate your value as string here



I also recommend you to read this documentation, https://angular.io/api/common/NgClass






share|improve this answer
































    1














    you have to assign value to string as this:



    myvalue: string;


    ngOnInit()
    this.myvalue = 6;






    share|improve this answer






























      0














      I wouldn't recommend @shadowman_93's solution. We have property binding for a reason. There's no reason to change CSS decorators in your component for this. It makes more sense to keep 'col-md' in your template, that way if you ever need to change it you will find it in an intuitive place, not in a string literal in your component. Thats just bad design.



      Strings are not functions. You are setting your string as if you are calling a set function for it. Strings in Typescript work like strings in pretty much every other language, so



      ngOnInit() 
      this.myvalue = '6';






      share|improve this answer























      • I think the point is, he is trying to undestand how [ngClass] property and function call's are works. Sometimes you need to explore pros and cons or needs of your app by yourself. So I'm not pro consultant here, just trying to show anyone the way of doing someting. Methods/ways can be increased.

        – shadowman_93
        Mar 8 at 21:12











      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55062343%2fangular-7-issue-with-passing-value-to-components-html%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Try this,



      app.component.html



      <div [ngClass]="myvalue">...</div>


      app.component.ts



      myvalue: string;
      ngOnInit()
      this.myvalue = 'col-md-'+'6'; //concatenate your value as string here



      If you want to pass data using with function, you can achieve it by using this approach,



      myvalue: string;
      ngOnInit()
      this.setValue('6');


      setValue(val: string)
      this.myvalue = 'col-md-'+val; //concatenate your value as string here



      I also recommend you to read this documentation, https://angular.io/api/common/NgClass






      share|improve this answer





























        0














        Try this,



        app.component.html



        <div [ngClass]="myvalue">...</div>


        app.component.ts



        myvalue: string;
        ngOnInit()
        this.myvalue = 'col-md-'+'6'; //concatenate your value as string here



        If you want to pass data using with function, you can achieve it by using this approach,



        myvalue: string;
        ngOnInit()
        this.setValue('6');


        setValue(val: string)
        this.myvalue = 'col-md-'+val; //concatenate your value as string here



        I also recommend you to read this documentation, https://angular.io/api/common/NgClass






        share|improve this answer



























          0












          0








          0







          Try this,



          app.component.html



          <div [ngClass]="myvalue">...</div>


          app.component.ts



          myvalue: string;
          ngOnInit()
          this.myvalue = 'col-md-'+'6'; //concatenate your value as string here



          If you want to pass data using with function, you can achieve it by using this approach,



          myvalue: string;
          ngOnInit()
          this.setValue('6');


          setValue(val: string)
          this.myvalue = 'col-md-'+val; //concatenate your value as string here



          I also recommend you to read this documentation, https://angular.io/api/common/NgClass






          share|improve this answer















          Try this,



          app.component.html



          <div [ngClass]="myvalue">...</div>


          app.component.ts



          myvalue: string;
          ngOnInit()
          this.myvalue = 'col-md-'+'6'; //concatenate your value as string here



          If you want to pass data using with function, you can achieve it by using this approach,



          myvalue: string;
          ngOnInit()
          this.setValue('6');


          setValue(val: string)
          this.myvalue = 'col-md-'+val; //concatenate your value as string here



          I also recommend you to read this documentation, https://angular.io/api/common/NgClass







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 11 at 7:40

























          answered Mar 8 at 11:39









          shadowman_93shadowman_93

          643314




          643314























              1














              you have to assign value to string as this:



              myvalue: string;


              ngOnInit()
              this.myvalue = 6;






              share|improve this answer



























                1














                you have to assign value to string as this:



                myvalue: string;


                ngOnInit()
                this.myvalue = 6;






                share|improve this answer

























                  1












                  1








                  1







                  you have to assign value to string as this:



                  myvalue: string;


                  ngOnInit()
                  this.myvalue = 6;






                  share|improve this answer













                  you have to assign value to string as this:



                  myvalue: string;


                  ngOnInit()
                  this.myvalue = 6;







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 8 at 11:34









                  Muhammad Abdullah ShafiqMuhammad Abdullah Shafiq

                  520114




                  520114





















                      0














                      I wouldn't recommend @shadowman_93's solution. We have property binding for a reason. There's no reason to change CSS decorators in your component for this. It makes more sense to keep 'col-md' in your template, that way if you ever need to change it you will find it in an intuitive place, not in a string literal in your component. Thats just bad design.



                      Strings are not functions. You are setting your string as if you are calling a set function for it. Strings in Typescript work like strings in pretty much every other language, so



                      ngOnInit() 
                      this.myvalue = '6';






                      share|improve this answer























                      • I think the point is, he is trying to undestand how [ngClass] property and function call's are works. Sometimes you need to explore pros and cons or needs of your app by yourself. So I'm not pro consultant here, just trying to show anyone the way of doing someting. Methods/ways can be increased.

                        – shadowman_93
                        Mar 8 at 21:12
















                      0














                      I wouldn't recommend @shadowman_93's solution. We have property binding for a reason. There's no reason to change CSS decorators in your component for this. It makes more sense to keep 'col-md' in your template, that way if you ever need to change it you will find it in an intuitive place, not in a string literal in your component. Thats just bad design.



                      Strings are not functions. You are setting your string as if you are calling a set function for it. Strings in Typescript work like strings in pretty much every other language, so



                      ngOnInit() 
                      this.myvalue = '6';






                      share|improve this answer























                      • I think the point is, he is trying to undestand how [ngClass] property and function call's are works. Sometimes you need to explore pros and cons or needs of your app by yourself. So I'm not pro consultant here, just trying to show anyone the way of doing someting. Methods/ways can be increased.

                        – shadowman_93
                        Mar 8 at 21:12














                      0












                      0








                      0







                      I wouldn't recommend @shadowman_93's solution. We have property binding for a reason. There's no reason to change CSS decorators in your component for this. It makes more sense to keep 'col-md' in your template, that way if you ever need to change it you will find it in an intuitive place, not in a string literal in your component. Thats just bad design.



                      Strings are not functions. You are setting your string as if you are calling a set function for it. Strings in Typescript work like strings in pretty much every other language, so



                      ngOnInit() 
                      this.myvalue = '6';






                      share|improve this answer













                      I wouldn't recommend @shadowman_93's solution. We have property binding for a reason. There's no reason to change CSS decorators in your component for this. It makes more sense to keep 'col-md' in your template, that way if you ever need to change it you will find it in an intuitive place, not in a string literal in your component. Thats just bad design.



                      Strings are not functions. You are setting your string as if you are calling a set function for it. Strings in Typescript work like strings in pretty much every other language, so



                      ngOnInit() 
                      this.myvalue = '6';







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Mar 8 at 18:29









                      TheBatmanTheBatman

                      1538




                      1538












                      • I think the point is, he is trying to undestand how [ngClass] property and function call's are works. Sometimes you need to explore pros and cons or needs of your app by yourself. So I'm not pro consultant here, just trying to show anyone the way of doing someting. Methods/ways can be increased.

                        – shadowman_93
                        Mar 8 at 21:12


















                      • I think the point is, he is trying to undestand how [ngClass] property and function call's are works. Sometimes you need to explore pros and cons or needs of your app by yourself. So I'm not pro consultant here, just trying to show anyone the way of doing someting. Methods/ways can be increased.

                        – shadowman_93
                        Mar 8 at 21:12

















                      I think the point is, he is trying to undestand how [ngClass] property and function call's are works. Sometimes you need to explore pros and cons or needs of your app by yourself. So I'm not pro consultant here, just trying to show anyone the way of doing someting. Methods/ways can be increased.

                      – shadowman_93
                      Mar 8 at 21:12






                      I think the point is, he is trying to undestand how [ngClass] property and function call's are works. Sometimes you need to explore pros and cons or needs of your app by yourself. So I'm not pro consultant here, just trying to show anyone the way of doing someting. Methods/ways can be increased.

                      – shadowman_93
                      Mar 8 at 21:12


















                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55062343%2fangular-7-issue-with-passing-value-to-components-html%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                      Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                      2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived