Dynamic assignment of ng-options in Angular causing unexpected behavior

I am currently working on an editable form that can be edited inline.

The directive I'm using passes down the ng-options to the template. Here's how it looks in a jade file:

div(input-inline-select="myobj.val" options="c.name for c in codes" tabindex="1")

Within the directive code:

scope.options = attr.options;

In the template where the select is rendered:

div(class="input_inline_edit_div")
  {{options}} 
  select(class="inline_edit_select" ng-options="{{options}}" ng-model="model" on-enter="save()" on-esc="cancel()" ng-show="editMode" tabindex="{{tabindex}}" ng-focus="edit()")
  span(ng-mouseenter="showEdit = true" ng-mouseleave="showEdit = false")
    span(ng-hide="editMode" ng-click="edit()" )
      div(class="inline_edit_text")
        {{model}}

The issue I'm facing is that the initial {{options}} displays the correct value of c.name for c in codes, but when used within ng-options="{{options}}" it does not work, causing the select options to disappear. Any insight into why this might be happening? Why does 'options' expand correctly on its own, but not as an attribute value?

Answer №1

Erase the {{}}

ng-options="options"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Scrolling with Selenium

Being a beginner in the world of Selenium, I am seeking guidance on the following issues: 1) What is the best way to automate scrolling on a webpage and make it stop when it reaches the height of the desktop? I need to capture screenshots of a full-screen ...

Ways to showcase Form utilizing function

I've just started learning React JS and bootstrap. I'm attempting to load a login form using a React JS class with an embedded function, but when the function is triggered on click event, it's not rendering the Form and instead displaying co ...

Display hierarchical JSON data in an Angular table

I'm attempting to display nested data from JSON in a table, but I'm having trouble achieving success. My JSON data:- $scope.data = [ { "$id": "1", "Folder": [ { "Name": "Windows-Desktop", "CPU": "2", ...

What is the best way to instantiate a service (injectable) with Angular within a class?

import { Store } from '@ngxs/store'; export class Service { constructor(private _store: Store) {} } export abstract class A { constructor( private _service: Service ) { } } export class B extends A { constructor( private _service: ...

Creating dynamic backend routes in NextJS is a great way to add flexibility to

Is there a way for me to implement dynamic backend routes? I am working on an image hosting platform where users should be able to save their images on the server under unique domains like http://localhost/<random_id>. An example link would look so ...

Access specific object in array in Angular using its unique identifier

There is an array presented below: this.questions = [ {id: 1, question: "Do you feel a connection to a higher source and have a sense of comfort knowing that you are part of something greater than yourself?", category: "Spiritual", subs: []}, ...

Understanding the significance behind `() => {}` syntax in ReactJS

While following along with a React tutorial, I stumbled upon the following code snippet: setTimeout(() => { this.setState({name: "Bob"}); }, 1000) As someone who is still getting acquainted with JavaScript, I must admit that I am unsure about ...

Having difficulty positioning the Divider correctly among Grid items

I am trying to add a Divider between each item in my Grid. The desired output should resemble this:- Col 1 | Col 2 | Col 3 However, I am facing difficulties as the Divider is not visible and the items are displayed vertically. import "./style ...

How can I retrieve the text input from a physical barcode scanner in a React Native screen?

Currently, I am developing a mobile application with React Native version 0.68.2. I am seeking a solution to detect barcode scanning events from a physical scanner hardware that is integrated into the mobile device as a handheld scanner. The key requirem ...

timings and pauses utilizing JavaScript

Currently, I am facing a challenge while working on a Simon Says game. My struggle lies in the part where I need to illuminate the buttons that the user has to click. I am using a "for" loop to iterate through each element in the array where I have stored ...

Unable to locate or modify an item within an array

I have a unique way of organizing my collection, with an array inside. Here's how it looks: const postsSchema = mongoose.Schema({ posts: {type: Array}, }) Now, I want to search for a specific document within this collection. I attempted the follo ...

According to Intelijj IDEA, the success function in the AJAX request is reported as unused

I've encountered an issue and I'm unsure of the cause. This is my code for testing AJAX requests: function sendAJAX() { var dataToSend = {}; dataToSend["username"] = $("#username").val(); dataToSend["age"] = $("#age").val(); data ...

Integrating information from various sources to create a cohesive online platform

I am looking to incorporate data from various sources into a single web page: Social networks (Facebook, Twitter, LinkedIn, etc.) RSS feeds Article meta tags (particularly OpenGraph and Twitter cards) This data may change dynamically based on user inter ...

Creating a JSON structure using an array in Typescript

Here is an example of my array structure: [ { "detail": "item1", "status": "active", "data": "item1_data" }, { "detail": "item2", "status": ...

Mastering intricate string manipulation using JavaScript regular expressions

I have a JavaScript/Node JS program that generates meaningful names according to the following rule: Input: "tenancy_account__accountPublicId__workspace__workspacePublicId__remove-user__userPublicId" Expected output: "TenancyAccountAcco ...

Unwanted border appearing on jQuery Carousel Plugin

I am currently using the showbiz jQuery carousel on my products page. I have encountered an issue where, upon clicking the "view more" button, an unwanted border appears around the carousel, but only in Chrome. How can I go about removing this border? Her ...

Tips on attaining the desired CSS impact

I'm curious about the method used by the creators of carv.ai to achieve the text masking effect seen on the paragraph "Carv connects wirelessly ...". I'm aware of how background images can be masked on text. ...

Is there a way to efficiently return an array of object and nested object keys with their full paths through recursion

My grasp of JS is still in its early stages, so understanding how the stack and recursion function can be challenging for me at this point. The task at hand involves displaying an array of object keys, including the parent object name if the object is nest ...

What are some strategies for receiving multiple responses with just one ajax request?

. I am having trouble grasping the concept of using ajax and how to get multiple responses while passing a single request. Can anyone provide me with a sample code to help me understand better? ...

Error: Cannot access the length property of an undefined value in the JEST test

I'm currently working on incorporating jest tests into my project, but I encountered an error when running the test. The issue seems to be related to a missing length method in the code that I am attempting to test. It appears to be originating from s ...