data from socket doesn't show in view Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Nativescript - Pass array from home-view-model to home.jsissue with controller somehow preventing my view widgets to showTap on event inside List-ViewAttaching Data To View NativeScript NG2Nativescript App Not Printing to ConsoleTap event not working on html view nativescriptHow to show the most right scroll view item which it's items are dynamic?Nativescript observable/async won't show in ListViewAngular6/Socket: socket call triggers “console.log()”, but fails in other functionsHow do I get value from the custom component Floating Label?

Did Krishna say in Bhagavad Gita "I am in every living being"

Significance of Cersei's obsession with elephants?

Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?

ArcGIS Pro Python arcpy.CreatePersonalGDB_management

Using et al. for a last / senior author rather than for a first author

Disembodied hand growing fangs

Question about debouncing - delay of state change

Trademark violation for app?

How can I reduce the gap between left and right of cdot with a macro?

Why do we need to use the builder design pattern when we can do the same thing with setters?

What do you call the main part of a joke?

Should I use a zero-interest credit card for a large one-time purchase?

Does the Weapon Master feat grant you a fighting style?

Is it fair for a professor to grade us on the possession of past papers?

As a beginner, should I get a Squier Strat with a SSS config or a HSS?

When a candle burns, why does the top of wick glow if bottom of flame is hottest?

An adverb for when you're not exaggerating

How would a mousetrap for use in space work?

Export Xpubkey from Bitcoin Core

How do living politicians protect their readily obtainable signatures from misuse?

Did Deadpool rescue all of the X-Force?

Can a new player join a group only when a new campaign starts?

Are all finite dimensional hilbert spaces isomorphic to spaces with Euclidean norms?

Find 108 by using 3,4,6



data from socket doesn't show in view



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Nativescript - Pass array from home-view-model to home.jsissue with controller somehow preventing my view widgets to showTap on event inside List-ViewAttaching Data To View NativeScript NG2Nativescript App Not Printing to ConsoleTap event not working on html view nativescriptHow to show the most right scroll view item which it's items are dynamic?Nativescript observable/async won't show in ListViewAngular6/Socket: socket call triggers “console.log()”, but fails in other functionsHow do I get value from the custom component Floating Label?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I get data from socket io but doesn't show in view.



I have this function in ts:



 socketIO.on('hello', (data) => 
console.log('data', data);
this.mydata= data;
);


Data in console show like this:



data
"nr": "123456789456"



in htm Nativescript:



<StackLayout >
<Label [text]='mydata'></Label>
</StackLayout>


How to display in view my data? In console data show correctly










share|improve this question
























  • I can see that data is JSON. You should convert it to string like JSON.stringify(data). If it still not works, try this syntax [(ngModel)]="mydata"

    – Juky
    Mar 22 at 10:57


















0















I get data from socket io but doesn't show in view.



I have this function in ts:



 socketIO.on('hello', (data) => 
console.log('data', data);
this.mydata= data;
);


Data in console show like this:



data
"nr": "123456789456"



in htm Nativescript:



<StackLayout >
<Label [text]='mydata'></Label>
</StackLayout>


How to display in view my data? In console data show correctly










share|improve this question
























  • I can see that data is JSON. You should convert it to string like JSON.stringify(data). If it still not works, try this syntax [(ngModel)]="mydata"

    – Juky
    Mar 22 at 10:57














0












0








0








I get data from socket io but doesn't show in view.



I have this function in ts:



 socketIO.on('hello', (data) => 
console.log('data', data);
this.mydata= data;
);


Data in console show like this:



data
"nr": "123456789456"



in htm Nativescript:



<StackLayout >
<Label [text]='mydata'></Label>
</StackLayout>


How to display in view my data? In console data show correctly










share|improve this question
















I get data from socket io but doesn't show in view.



I have this function in ts:



 socketIO.on('hello', (data) => 
console.log('data', data);
this.mydata= data;
);


Data in console show like this:



data
"nr": "123456789456"



in htm Nativescript:



<StackLayout >
<Label [text]='mydata'></Label>
</StackLayout>


How to display in view my data? In console data show correctly







angular nativescript






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 10:21







ona bin

















asked Mar 22 at 10:03









ona binona bin

52




52












  • I can see that data is JSON. You should convert it to string like JSON.stringify(data). If it still not works, try this syntax [(ngModel)]="mydata"

    – Juky
    Mar 22 at 10:57


















  • I can see that data is JSON. You should convert it to string like JSON.stringify(data). If it still not works, try this syntax [(ngModel)]="mydata"

    – Juky
    Mar 22 at 10:57

















I can see that data is JSON. You should convert it to string like JSON.stringify(data). If it still not works, try this syntax [(ngModel)]="mydata"

– Juky
Mar 22 at 10:57






I can see that data is JSON. You should convert it to string like JSON.stringify(data). If it still not works, try this syntax [(ngModel)]="mydata"

– Juky
Mar 22 at 10:57













5 Answers
5






active

oldest

votes


















0














Make sure you are running inside ngZone



....

constructor(private zone:NgZone)
super()


....
socketIO.on('hello', (data) =>
this.zone.run(()=>
console.log('data', data);
this.mydata= data;
);
);





share|improve this answer






























    0














    you can use binding like this -




    <StackLayout >
    <Label text= mydata ></Label>
    </StackLayout>


    Let me know if it works.



    For further reading read docs here






    share|improve this answer























    • Doesn't show and like this binding. I put in my post and JSON data

      – ona bin
      Mar 22 at 10:20



















    0














    can you try like this



    TS:



     mydata: any;
    const self = this;
    socketIO.on('hello', (data) =>
    console.log('data', data);
    self.mydata= data;
    );


    HTML:



     <StackLayout>
    <Label [text]='mydata'></Label>
    </StackLayout>


    let me know if it works






    share|improve this answer






























      0














      From console's output I see that data is an object. Shouldn't the [text] input on <Label> be a string?






      share|improve this answer






























        0














        You may have to trigger change detection after assignent
        https://angular.io/api/core/ChangeDetectorRef#markforcheck



        class componant 
        constructor(private cdf:ChangeDetectorRef)

        socketIO.on('hello', (data) =>
        console.log('data', data);
        this.mydata= data;
        this.cdf.markForCheck()
        );







        share|improve this answer























          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%2f55297180%2fdata-from-socket-doesnt-show-in-view%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Make sure you are running inside ngZone



          ....

          constructor(private zone:NgZone)
          super()


          ....
          socketIO.on('hello', (data) =>
          this.zone.run(()=>
          console.log('data', data);
          this.mydata= data;
          );
          );





          share|improve this answer



























            0














            Make sure you are running inside ngZone



            ....

            constructor(private zone:NgZone)
            super()


            ....
            socketIO.on('hello', (data) =>
            this.zone.run(()=>
            console.log('data', data);
            this.mydata= data;
            );
            );





            share|improve this answer

























              0












              0








              0







              Make sure you are running inside ngZone



              ....

              constructor(private zone:NgZone)
              super()


              ....
              socketIO.on('hello', (data) =>
              this.zone.run(()=>
              console.log('data', data);
              this.mydata= data;
              );
              );





              share|improve this answer













              Make sure you are running inside ngZone



              ....

              constructor(private zone:NgZone)
              super()


              ....
              socketIO.on('hello', (data) =>
              this.zone.run(()=>
              console.log('data', data);
              this.mydata= data;
              );
              );






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Mar 22 at 11:02









              ManojManoj

              8,19921024




              8,19921024























                  0














                  you can use binding like this -




                  <StackLayout >
                  <Label text= mydata ></Label>
                  </StackLayout>


                  Let me know if it works.



                  For further reading read docs here






                  share|improve this answer























                  • Doesn't show and like this binding. I put in my post and JSON data

                    – ona bin
                    Mar 22 at 10:20
















                  0














                  you can use binding like this -




                  <StackLayout >
                  <Label text= mydata ></Label>
                  </StackLayout>


                  Let me know if it works.



                  For further reading read docs here






                  share|improve this answer























                  • Doesn't show and like this binding. I put in my post and JSON data

                    – ona bin
                    Mar 22 at 10:20














                  0












                  0








                  0







                  you can use binding like this -




                  <StackLayout >
                  <Label text= mydata ></Label>
                  </StackLayout>


                  Let me know if it works.



                  For further reading read docs here






                  share|improve this answer













                  you can use binding like this -




                  <StackLayout >
                  <Label text= mydata ></Label>
                  </StackLayout>


                  Let me know if it works.



                  For further reading read docs here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 22 at 10:07









                  TodarmalTodarmal

                  11610




                  11610












                  • Doesn't show and like this binding. I put in my post and JSON data

                    – ona bin
                    Mar 22 at 10:20


















                  • Doesn't show and like this binding. I put in my post and JSON data

                    – ona bin
                    Mar 22 at 10:20

















                  Doesn't show and like this binding. I put in my post and JSON data

                  – ona bin
                  Mar 22 at 10:20






                  Doesn't show and like this binding. I put in my post and JSON data

                  – ona bin
                  Mar 22 at 10:20












                  0














                  can you try like this



                  TS:



                   mydata: any;
                  const self = this;
                  socketIO.on('hello', (data) =>
                  console.log('data', data);
                  self.mydata= data;
                  );


                  HTML:



                   <StackLayout>
                  <Label [text]='mydata'></Label>
                  </StackLayout>


                  let me know if it works






                  share|improve this answer



























                    0














                    can you try like this



                    TS:



                     mydata: any;
                    const self = this;
                    socketIO.on('hello', (data) =>
                    console.log('data', data);
                    self.mydata= data;
                    );


                    HTML:



                     <StackLayout>
                    <Label [text]='mydata'></Label>
                    </StackLayout>


                    let me know if it works






                    share|improve this answer

























                      0












                      0








                      0







                      can you try like this



                      TS:



                       mydata: any;
                      const self = this;
                      socketIO.on('hello', (data) =>
                      console.log('data', data);
                      self.mydata= data;
                      );


                      HTML:



                       <StackLayout>
                      <Label [text]='mydata'></Label>
                      </StackLayout>


                      let me know if it works






                      share|improve this answer













                      can you try like this



                      TS:



                       mydata: any;
                      const self = this;
                      socketIO.on('hello', (data) =>
                      console.log('data', data);
                      self.mydata= data;
                      );


                      HTML:



                       <StackLayout>
                      <Label [text]='mydata'></Label>
                      </StackLayout>


                      let me know if it works







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Mar 22 at 10:24









                      Yash RamiYash Rami

                      46137




                      46137





















                          0














                          From console's output I see that data is an object. Shouldn't the [text] input on <Label> be a string?






                          share|improve this answer



























                            0














                            From console's output I see that data is an object. Shouldn't the [text] input on <Label> be a string?






                            share|improve this answer

























                              0












                              0








                              0







                              From console's output I see that data is an object. Shouldn't the [text] input on <Label> be a string?






                              share|improve this answer













                              From console's output I see that data is an object. Shouldn't the [text] input on <Label> be a string?







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Mar 22 at 10:47









                              mbojkombojko

                              2,3111314




                              2,3111314





















                                  0














                                  You may have to trigger change detection after assignent
                                  https://angular.io/api/core/ChangeDetectorRef#markforcheck



                                  class componant 
                                  constructor(private cdf:ChangeDetectorRef)

                                  socketIO.on('hello', (data) =>
                                  console.log('data', data);
                                  this.mydata= data;
                                  this.cdf.markForCheck()
                                  );







                                  share|improve this answer



























                                    0














                                    You may have to trigger change detection after assignent
                                    https://angular.io/api/core/ChangeDetectorRef#markforcheck



                                    class componant 
                                    constructor(private cdf:ChangeDetectorRef)

                                    socketIO.on('hello', (data) =>
                                    console.log('data', data);
                                    this.mydata= data;
                                    this.cdf.markForCheck()
                                    );







                                    share|improve this answer

























                                      0












                                      0








                                      0







                                      You may have to trigger change detection after assignent
                                      https://angular.io/api/core/ChangeDetectorRef#markforcheck



                                      class componant 
                                      constructor(private cdf:ChangeDetectorRef)

                                      socketIO.on('hello', (data) =>
                                      console.log('data', data);
                                      this.mydata= data;
                                      this.cdf.markForCheck()
                                      );







                                      share|improve this answer













                                      You may have to trigger change detection after assignent
                                      https://angular.io/api/core/ChangeDetectorRef#markforcheck



                                      class componant 
                                      constructor(private cdf:ChangeDetectorRef)

                                      socketIO.on('hello', (data) =>
                                      console.log('data', data);
                                      this.mydata= data;
                                      this.cdf.markForCheck()
                                      );








                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Mar 22 at 11:25









                                      AbdulKareemAbdulKareem

                                      452314




                                      452314



























                                          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%2f55297180%2fdata-from-socket-doesnt-show-in-view%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

                                          Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

                                          밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

                                          1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴