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

                      Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                      Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

                      How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page