Unable to display specific data in Drop Down using AngularJS

I've encountered an issue with my dropdown menu not displaying data when I select the appropriate option. There are two choices available.

CSHTML

<ui-select ng-model="ctrl.requestType" theme="selectize" title="Choose type of requisition" style="min-width: 140px;">

  <ui-select-match placeholder="Select type of requisition">
    <span ng-bind="$select.selected.name"></span>
  </ui-select-match>

  <ui-select-choices repeat="existingRequestType.name as existingRequestType in ctrl.existingRequestTypes | filter: $select.search">

    <span ng-bind-html="existingRequestType.name| highlight: $select.search"> - 
       </span>
  </ui-select-choices>
</ui-select>

Angular.JS format

app.controller('myCtrl', function($scope, $http, $timeout, $interval) {
      vm.existingRequestTypes = [{
          name: 'Purchase'
        },
        {
          name: 'Lease'
        }
      ];
    }

Appreciate any assistance provided!

Answer №1

I have a feeling that you may have overlooked defining the variable vm:

app.controller('myCtrl', function($scope, $http, $timeout, $interval) {
  var vm = this;

  vm.existingRequestTypes = [{
      name: 'Purchase'
    },
    {
      name: 'Lease'
    }
  ];
}

OR

app.controller('myCtrl', function($scope, $http, $timeout, $interval) {
  $scope.existingRequestTypes = [{
      name: 'Purchase'
    },
    {
      name: 'Lease'
    }
  ];
}

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

Building conditionals in AngularJS expressions using if-then-else syntax

Is there a way to incorporate the ternary-operator (if-then-else construction) in an angularjs expression? For example, I have a function $scope.isExists(item) that should return a boolean value. I would like to do something like this: <div ng-repeater ...

Where would you start looking if the right side of a table border is not visible?

Where should I start looking if the right side border of a table element in a div is not visible? ...

What are the benefits of refraining from calling functions in AngularJS views to showcase data in a more objective manner?

In our work application, we have a function that generates various objects inheriting methods from a prototype. To summarize, this function creates instances of the MileCounter object. Here is an example: function MileCounter(totalMilesRan, numOfDaysToRu ...

When bootstrap is imported, SVG is displayed with a square background

The combination of reactJS and bootstrap has caused an unexpected issue for me. After importing bootstrap, strange squares have started to appear behind my SVG images... https://i.sstatic.net/4vmP8.png Is anyone familiar with what is causing this and ho ...

Use PHP to create a new JSON file on the server by submitting a form, then utilize a second form to update

My current goal is to create a json file using a form and then update that file with another form. Both of these processes are handled in the process.php file. I have managed to successfully update the json file if it is named as data.json initially in pro ...

Optimizing Safari for the Best Screen Size Experience

I seem to be encountering issues with optimizing my website. Everything appears to be working correctly in terms of widths, heights, margins, etc., on my laptop. However, when I view the site on an iMac or any other computer with a larger screen size, the ...

Having trouble with data retrieval from MySQL using PHP and Angular on certain mobile devices, although it functions properly on desktops and laptops

The data retrieved from the mysql database is functioning properly on desktop and laptop, but not on mobile devices. The following HTML code is present in the html file: <table class="table table-default"> <thead> <tr> & ...

Displaying images on hover that were not initially incorporated into the project

I am currently developing a website where the content is not controlled by me and the incoming content is unknown, making it impossible for me to store images. My goal is to display the referenced image when a specific class is hovered over. For example: ...

How to create a customized "Sent" Page using PHPMailer

Recently, I've delved into using PHPMailer to handle my contact forms via email and after some trial and error, everything is running smoothly. The only minor inconvenience is that users are redirected after sending an email. For instance: If a user ...

Concealing and Revealing a Div Element in HTML

Every time the page is refreshed, I am encountering a strange issue where I need to double click a button in order to hide a block. Below is the code snippet for reference: <!DOCTYPE html> <html> <head> <meta name="viewport&quo ...

What is the best way to manage the changing selection in a drop-down list?

Can someone help me with a coding issue I am facing? <select name="txtTK" > <option value="None">---</option> <option value="Mat">Materials</option> <option value="Cate">Category</option> <option ...

generate an electronic communication using an HTML and PHP template

Currently, I am working on a PHP web application that requires sending emails in HTML format. To achieve this, I am utilizing the mail() function. My goal is to send emails based on a template file that is formatted in HTML and includes segments of PHP ...

Adjust the height of the div container and implement a vertical scroll feature on the fixed element

I created a fiddle and was hoping to enable scrolling, but I have been unable to find a solution. http://jsfiddle.net/sq181h3h/3/ I tried both of these options, but nothing seems to be working: #league_chat { overflow-y:scroll; } #league_chat { ...

The Challenge of Referencing Javascript Files (including jQuery)

Previously, I had the following code snippet: <head> <script src="/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script> <script type="text/javascript"> var optPrompt = "- Select One -"; var subCats ...

Creating a "select all" feature in an HTML multiple select box with jQuery - a step-by-step guide

I'm currently working on an HTML form that includes a multiple select box. I am looking to create a "select all" option within the multiple select box so that when a user clicks on that option, all other options in the select box are automatically sel ...

Obtain the value of "data-something" attribute from an <option> element within a <select> element

Can anyone help me with this HTML snippet? <select id="something"> <option value="1" data-something="true">Something True</option> <option value="2" data-something-else="false">Something Else False</option> </selec ...

Using jSLint in combination with Angular leads to an unexpected error regarding the variable "$scope"

When performing a jSLint check on my Angular-based app, I encountered an "Unexpected '$scope'" error. To replicate the issue, you can try inputting the code snippet below into jslint.com. I'm puzzled as to why the first function declaration ...

Stop Gmail from Removing Attached HTML Files

I successfully developed an HTML file with its own CSS styling and custom HEAD tags to ensure it displays well in mobile browsers. I managed to make it work with PHP as a file attachment. However, the issue arises when Gmail distorts the view of the file ...

Fixing a div at the top post scroll - bug on iOS mobile device

I am looking to achieve a similar effect as demonstrated in the example below: https://css-tricks.com/scroll-fix-content/ Essentially, the goal is to have a div become fixed at the top of the page after scrolling to a certain point. Initially, the div wil ...

The table is refusing to align itself in the center

I've been struggling to center the text inside this table despite trying various solutions. Any help would be greatly appreciated. Here's the HTML code I have: <div id="paccount"> <table style="margin: 0 auto;"> <tr&g ...