Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9186253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:28:47+00:00 2026-06-17T19:28:47+00:00

I’m new to AngularJS and can’t find any suitable answer for this. My app

  • 0

I’m new to AngularJS and can’t find any suitable answer for this. My app currently consists of a list of items displayed via Angular. There is also a label which displays the name of the currently selected item, and an input box which allows the name of the currently selected item to be modified.

What I cannot figure out is how to simultaneously:

  1. Allow the selection of an item, which triggers the update of the label and the input box text to display the name of the newly selected item
  2. Allow editing of the name in the input box which triggers the update of the label displaying the currently displayed item name
  3. Edits to the name should be reflected in the original model item

At the moment, i’m trying to keep track of which item is current via a flag against the item and this isn’t doing what I want. Ideally I would replace currentItem in the below with a direct reference to the item in items with isCurrent=true.

Current item name label:

`<div id="CurrentItem" data-ng-model="currentItem">{{currentItem.name}}</div>`

Current item name input box:

`<input id="ItemName" type="text" data-ng-model="currentItem" value="{{currentItem.name}}" />`

Display all items:

<div data-ng-repeat="item in items" data-ng-click="changeItem(item)">`
    <img src="images/ItemIcon.png">
<div>{{item.name}}</div>

Controller:

var CoreAppController = function($scope, $location) {
   $scope.changeItem = function(item) {
        var length = $scope.items.length;
        while(length-- ) {
            $scope.items[length].isCurrent = false;
        }
        $scope.currentItem = item;
        $scope.items.indexOf(item).isCurrent = false;
    }

    $scope.createItem = function(name, layout) {
        $scope.items.push({ id: $scope.items.length + 1,
                            name: name,
                            isCurrent: false
        });
    }

    // Initialisation
    $scope.items = [];
    $scope.createItem("Item 1");
    $scope.createItem("Item 2");

    $scope.items[0].isCurrent = true;
    $scope.currentItem = $scope.items[0];

}

Any advice appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:28:49+00:00Added an answer on June 17, 2026 at 7:28 pm

    I’m not sure about your current code, but here is a mock up that does what it appears you’re requesting.

    The JS

    app.controller('MainCtrl', function($scope) {
      $scope.items = [
        { name: 'foo' },
        { name: 'bar' },
        { name: 'test' }
        ];
        $scope.editing = null;
        $scope.editItem = function(item) {
          $scope.editing = item;
        }
    });
    

    and the markup

      <body ng-controller="MainCtrl">
        <ul>
          <li ng-repeat="item in items">
            {{item.name}}
            <a ng-click="editItem(item);">edit</a>
          </li>
        </ul>
        <div ng-show="editing">
           <input type="text" ng-model="editing.name"/>
           <span>{{editing.name}}</span>
        </div>
      </body>
    

    Hopefully that helps. If you need more of a description, let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.