I need to print countries based on option selected in array in my code dynamicallyBinding select element to object in AngularHow do you remove all the options of a select box and then add one option and select it with jQuery?What is the best way to add options to a select from as a JS object with jQuery?Adding options to a <select> using jQuery?Frame Buster Buster … buster code neededSimplest code for array intersection in javascriptSelecting last element in JavaScript arrayjQuery Get Selected Option From DropdownWorking with select using AngularJS's ng-optionsReact JSX: selecting “selected” on selected <select> optionAngularJS - select option and use it in a function

Metric version of "footage"?

When is pointing out a person's hypocrisy not considered to be a logical fallacy?

Does Google Maps take into account hills/inclines for route times?

Too many spies!

Rearranging the formula

latinate or other words of foreign origin as opposed to Germanic words

Ambiguous sentences: How to tell when they need fixing?

P-MOSFET failing

How do I write a romance that doesn't look obvious

nginx serves wrong domain site. It doenst shows default site if no configuration applies

Why would guns not work in the dungeon?

Why did my rum cake turn black?

Is `curl something | sudo bash -` a reasonably safe installation method?

Filtering fine silt/mud from water (not necessarily bacteria etc.)

Can a continent naturally split into two distant parts within a week?

Is it rude to tell recruiters I would only change jobs for a better salary?

How might the United Kingdom become a republic?

What is the English equivalent of 干物女 (dried fish woman)?

I quit, and boss offered me 3 month "grace period" where I could still come back

Can anybody provide any information about this equation?

As a DM, how to avoid unconscious metagaming when dealing with a high AC character?

Why does java.time.Period#normalized() not normalize days?

Can you negate disadvantage on throwing a net by using the Lunging Attack maneuver of the Battle Master fighter?

Fix /dev/sdb after using dd with no device inserted



I need to print countries based on option selected in array in my code dynamically


Binding select element to object in AngularHow do you remove all the options of a select box and then add one option and select it with jQuery?What is the best way to add options to a select from as a JS object with jQuery?Adding options to a <select> using jQuery?Frame Buster Buster … buster code neededSimplest code for array intersection in javascriptSelecting last element in JavaScript arrayjQuery Get Selected Option From DropdownWorking with select using AngularJS's ng-optionsReact JSX: selecting “selected” on selected <select> optionAngularJS - select option and use it in a function






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I need simple code help. If I choose any particular letter then corresponding countries should be displayed, in my current position I am not able to do it dynamically.
For example if i choose letter A then countries pertaining to those should be displayed outside the select.



<select [(ngModel)]="selectedOption">
<option *ngFor="let o of options">
o.letter
</option>
</select>

<p *ngFor="let o of options">Countries are: o.countries </p>



export class AppComponent 
selectedOption: string;

options = [
letter: "A", countries: ["Afghanistan", "Albania", "Argentina"] ,
letter: "B", countries: ["Bangladesh", "Bahamas", "Bahrain"]
]





If A chosen then Afghanistan Albania ....
If B chosen then ....
If C chosen then .... I should be able to expand array in future.










share|improve this question




























    2















    I need simple code help. If I choose any particular letter then corresponding countries should be displayed, in my current position I am not able to do it dynamically.
    For example if i choose letter A then countries pertaining to those should be displayed outside the select.



    <select [(ngModel)]="selectedOption">
    <option *ngFor="let o of options">
    o.letter
    </option>
    </select>

    <p *ngFor="let o of options">Countries are: o.countries </p>



    export class AppComponent 
    selectedOption: string;

    options = [
    letter: "A", countries: ["Afghanistan", "Albania", "Argentina"] ,
    letter: "B", countries: ["Bangladesh", "Bahamas", "Bahrain"]
    ]





    If A chosen then Afghanistan Albania ....
    If B chosen then ....
    If C chosen then .... I should be able to expand array in future.










    share|improve this question
























      2












      2








      2


      1






      I need simple code help. If I choose any particular letter then corresponding countries should be displayed, in my current position I am not able to do it dynamically.
      For example if i choose letter A then countries pertaining to those should be displayed outside the select.



      <select [(ngModel)]="selectedOption">
      <option *ngFor="let o of options">
      o.letter
      </option>
      </select>

      <p *ngFor="let o of options">Countries are: o.countries </p>



      export class AppComponent 
      selectedOption: string;

      options = [
      letter: "A", countries: ["Afghanistan", "Albania", "Argentina"] ,
      letter: "B", countries: ["Bangladesh", "Bahamas", "Bahrain"]
      ]





      If A chosen then Afghanistan Albania ....
      If B chosen then ....
      If C chosen then .... I should be able to expand array in future.










      share|improve this question














      I need simple code help. If I choose any particular letter then corresponding countries should be displayed, in my current position I am not able to do it dynamically.
      For example if i choose letter A then countries pertaining to those should be displayed outside the select.



      <select [(ngModel)]="selectedOption">
      <option *ngFor="let o of options">
      o.letter
      </option>
      </select>

      <p *ngFor="let o of options">Countries are: o.countries </p>



      export class AppComponent 
      selectedOption: string;

      options = [
      letter: "A", countries: ["Afghanistan", "Albania", "Argentina"] ,
      letter: "B", countries: ["Bangladesh", "Bahamas", "Bahrain"]
      ]





      If A chosen then Afghanistan Albania ....
      If B chosen then ....
      If C chosen then .... I should be able to expand array in future.







      javascript angular typescript






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 26 at 5:37









      R.HR.H

      8710 bronze badges




      8710 bronze badges






















          2 Answers
          2






          active

          oldest

          votes


















          2














          You can use ngValue instead of using ngFor.
          You can refer this answer.
          Here is the working example.



          Your code becomes



          <select [(ngModel)]="selectedOption">
          <option *ngFor="let o of options" [ngValue]="o">
          o.letter
          </option>
          </select>

          <!-- Just to debug and display selected object -->
          json

          <p>selectedOption.countries</p>





          share|improve this answer






























            0














            You can try this



            <p *ngFor="let o of options">
            <label *ngIf="o.letter === selectedOption">Countries are: o.countries <label>
            </p>





            share|improve this answer

























            • Template parse errors: Can't have multiple template bindings on one element

              – R.H
              Mar 26 at 5:43











            • I've modified the answer. Could you try that?

              – Seba Cherian
              Mar 26 at 5:45














            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%2f55350479%2fi-need-to-print-countries-based-on-option-selected-in-array-in-my-code-dynamical%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            You can use ngValue instead of using ngFor.
            You can refer this answer.
            Here is the working example.



            Your code becomes



            <select [(ngModel)]="selectedOption">
            <option *ngFor="let o of options" [ngValue]="o">
            o.letter
            </option>
            </select>

            <!-- Just to debug and display selected object -->
            json

            <p>selectedOption.countries</p>





            share|improve this answer



























              2














              You can use ngValue instead of using ngFor.
              You can refer this answer.
              Here is the working example.



              Your code becomes



              <select [(ngModel)]="selectedOption">
              <option *ngFor="let o of options" [ngValue]="o">
              o.letter
              </option>
              </select>

              <!-- Just to debug and display selected object -->
              json

              <p>selectedOption.countries</p>





              share|improve this answer

























                2












                2








                2







                You can use ngValue instead of using ngFor.
                You can refer this answer.
                Here is the working example.



                Your code becomes



                <select [(ngModel)]="selectedOption">
                <option *ngFor="let o of options" [ngValue]="o">
                o.letter
                </option>
                </select>

                <!-- Just to debug and display selected object -->
                json

                <p>selectedOption.countries</p>





                share|improve this answer













                You can use ngValue instead of using ngFor.
                You can refer this answer.
                Here is the working example.



                Your code becomes



                <select [(ngModel)]="selectedOption">
                <option *ngFor="let o of options" [ngValue]="o">
                o.letter
                </option>
                </select>

                <!-- Just to debug and display selected object -->
                json

                <p>selectedOption.countries</p>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 26 at 5:47









                Laxmikant DangeLaxmikant Dange

                5,7013 gold badges31 silver badges57 bronze badges




                5,7013 gold badges31 silver badges57 bronze badges























                    0














                    You can try this



                    <p *ngFor="let o of options">
                    <label *ngIf="o.letter === selectedOption">Countries are: o.countries <label>
                    </p>





                    share|improve this answer

























                    • Template parse errors: Can't have multiple template bindings on one element

                      – R.H
                      Mar 26 at 5:43











                    • I've modified the answer. Could you try that?

                      – Seba Cherian
                      Mar 26 at 5:45
















                    0














                    You can try this



                    <p *ngFor="let o of options">
                    <label *ngIf="o.letter === selectedOption">Countries are: o.countries <label>
                    </p>





                    share|improve this answer

























                    • Template parse errors: Can't have multiple template bindings on one element

                      – R.H
                      Mar 26 at 5:43











                    • I've modified the answer. Could you try that?

                      – Seba Cherian
                      Mar 26 at 5:45














                    0












                    0








                    0







                    You can try this



                    <p *ngFor="let o of options">
                    <label *ngIf="o.letter === selectedOption">Countries are: o.countries <label>
                    </p>





                    share|improve this answer















                    You can try this



                    <p *ngFor="let o of options">
                    <label *ngIf="o.letter === selectedOption">Countries are: o.countries <label>
                    </p>






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Mar 26 at 6:01









                    Bhagwat Tupe

                    8054 silver badges19 bronze badges




                    8054 silver badges19 bronze badges










                    answered Mar 26 at 5:40









                    Seba CherianSeba Cherian

                    8791 silver badge14 bronze badges




                    8791 silver badge14 bronze badges












                    • Template parse errors: Can't have multiple template bindings on one element

                      – R.H
                      Mar 26 at 5:43











                    • I've modified the answer. Could you try that?

                      – Seba Cherian
                      Mar 26 at 5:45


















                    • Template parse errors: Can't have multiple template bindings on one element

                      – R.H
                      Mar 26 at 5:43











                    • I've modified the answer. Could you try that?

                      – Seba Cherian
                      Mar 26 at 5:45

















                    Template parse errors: Can't have multiple template bindings on one element

                    – R.H
                    Mar 26 at 5:43





                    Template parse errors: Can't have multiple template bindings on one element

                    – R.H
                    Mar 26 at 5:43













                    I've modified the answer. Could you try that?

                    – Seba Cherian
                    Mar 26 at 5:45






                    I've modified the answer. Could you try that?

                    – Seba Cherian
                    Mar 26 at 5:45


















                    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%2f55350479%2fi-need-to-print-countries-based-on-option-selected-in-array-in-my-code-dynamical%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

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript