JavaScript Can I set ng-model to two values? model values django,model values in javascript,model values in

I have an input

<input type="text" ng-model="choice.text">

Where choice.text creates a new text property in the object choice. This allows me to send the contents of the input to different page. While this feature works, I would also like to add another feature where the content of the input is displayed and updated in real time on the page. Something to this effect.

Unfortunately, ng-model is already set to choice.text. Is there a way I can have set two values to one ng-model? It would perhaps look like this:

<input type="text" ng-model="choice.text name"></p>
<p ng-bind="name"></p>

If not, is there another way to achieve this effect?

EDIT: For those wondering, when I try <p ng-bind="choice.text"></p>it doesnt work for some reason.

EDIT 2: I simplified the code for the sake of the question. Here is the actual code for more detail:

<div class ="ask-container">
    <div ng-switch="cbstate">
      <div ng-switch-when="not-pressed">
        <h1>Choose between... </h1> <!-- I would like to add the dynamic element here -->
      </div>
      <div ng-switch-when="pressed">
        <h1>Hi</h1>
      </div>
    </div>
    <form role="form" ng-submit="submitChoice()">
      <div class="input" ng-repeat="choice in poll.options">
        <input type="text"  ng-model="choice.text" placeholder="Choice {{$index+1}}"><br>
      </div>
      <button class="add" type="button" ng-click="addChoice()">+</button>
      <button class="create" type="submit">Create</button>
    </form>
</div>

EDIT 3: Same code, but with the ng-bind:

<div class ="ask-container">
    <div ng-switch="cbstate">
      <div ng-switch-when="not-pressed">
        <h1>Choose between... </h1>
      </div>
      <div ng-switch-when="pressed">
        <h1>Hi</h1>
      </div>
    </div>
    <form role="form" ng-submit="submitChoice()">
      <div class="input" ng-repeat="choice in poll.options">
        <input type="text"  ng-model="choice.text" ng-change="temp=choice.text" placeholder="Choice {{$index+1}}"><br>
      </div>
      <button class="add" type="button" ng-click="addChoice()">+</button>
      <button class="create" type="submit">Create</button>
    </form>
    <p ng-bind="temp"></p>
    <p ng-bind="choice.text"></p>
</div>

Note: Somebody said that the ng-repeat may be messing with my scope. Maybe keep that in mind as you try and fix my problem.

Answer:1

For now, just list[0]. Eventually I will want them all to appear in a list but I can do that myself. For now I just want the first input to display in the bind.

To have the first of the list appear in the bind:

<div class="input" ng-repeat="choice in poll.options">
  <input type="text"  ng-model="choice.text" placeholder="Choice {{$index+1}}" />
  <br>
</div>

<p ng-bind="poll.options[0].text"></p>

Each <div> in the ng-repeat has its own child scope with the choice property set to poll.options[0], poll.options[1], poll.options[2], etc. Simply use those values in the parent scope.

Answer:2

I am trying to append content inside a Gridster widget but with no luck for two days already. I tried with: .resize_widget( $widget, [size_x], [size_y], [reposition], [callback] ) but the sizes x ...

I am trying to append content inside a Gridster widget but with no luck for two days already. I tried with: .resize_widget( $widget, [size_x], [size_y], [reposition], [callback] ) but the sizes x ...

  1. gridster auto resize
  2. gridster auto resize height
  3. gridster resize
  4. gridster resizable

I'm learning WebGL, done that with the help of WebGLFundamentals page, which helped me pretty much to understand how buffers, shaders and all that stuff works. But now I want to achieve a certain ...

I'm learning WebGL, done that with the help of WebGLFundamentals page, which helped me pretty much to understand how buffers, shaders and all that stuff works. But now I want to achieve a certain ...

I have a commonly reused set of form inputs that are reused throughout my application, so I am trying to encapsulate them in a custom directive. I want to set an ngModel on my directive and have that ...

I have a commonly reused set of form inputs that are reused throughout my application, so I am trying to encapsulate them in a custom directive. I want to set an ngModel on my directive and have that ...

  1. ngmodel custom directive
  2. angularjs ng model custom directive
  3. ng-model inside custom directive
  4. angular ng-model custom directive
  5. require ngmodel in custom directive

_renderItem is not executing at all, tried with console.log too no messages printed. Tried with 'autocomplete', 'ui-autocomplete', 'Autocomplete' attributes no hope. In addition I could not ...

_renderItem is not executing at all, tried with console.log too no messages printed. Tried with 'autocomplete', 'ui-autocomplete', 'Autocomplete' attributes no hope. In addition I could not ...

  1. jquery autocomplete _renderitem not working
  2. jquery autocomplete _renderitem undefined
  3. jquery autocomplete _renderitem example
  4. jquery autocomplete _renderitem
  5. jquery autocomplete _renderitem multiple
  6. jquery autocomplete _renderitem select
  7. jquery autocomplete _renderitem table
  8. jquery ui autocomplete _renderitem
  9. jquery ui autocomplete _renderitem example
  10. jquery ui autocomplete _renderitem not working
  11. jquery autocomplete override renderitem
  12. jquery autocomplete ajax _renderitem
  13. jquery autocomplete custom renderitem
  14. jquery ui autocomplete _renderitem highlight
  15. jquery autocomplete data _renderitem
  16. jquery ui autocomplete custom renderitem
  17. jquery ui autocomplete override renderitem
  18. jquery autocomplete custom rendered item
  19. jquery autocomplete renderitem
  20. jquery ui autocomplete renderitem