Angular Search Panel

I'm having trouble with the Angular Search box not working when I try to run it locally on my computer. The same code works perfectly fine on platforms like codepen, plunker, and jsfiddle. Can someone help me figure out what's going wrong?

.example-animate-container {
  background:white;
  border:5px solid red;
  list-style:none;
  margin:0;
  padding:0 10px;
}

.animate-repeat {
  line-height:40px;
  list-style:none;
  box-sizing:border-box;
}

.animate-repeat.ng-move,
.animate-repeat.ng-enter,
.animate-repeat.ng-leave {
  -webkit-transition:all linear 0.5s;
  transition:all linear 0.5s;
}

.animate-repeat.ng-leave.ng-leave-active,
.animate-repeat.ng-move,
.animate-repeat.ng-enter {
  opacity:0;
  max-height:0;
}

.animate-repeat.ng-leave,
.animate-repeat.ng-move.ng-move-active,
.animate-repeat.ng-enter.ng-enter-active {
  opacity:1;
  max-height:40px;
}
<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8>
  <title>Example - example-example89-production</title>
  <link href="animations.css" rel="stylesheet" type="text/css">
  
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.1/angular.min.js"></script>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.1/angular-animate.js"><:/script>
  
</head>

<body ng-app="ngAnimate">
  <div ng-init="buildings = [
  {name:'Carver-Hawkeye Arena', location:'1 Elliott Drive Iowa City, IA', facility:'athletics', initials:'CHA'},
  {name:'Ronald McDonald House', location:'730 Hawkins Drive Iowa City, IA', facility:'athletics', initials:'RMCD'}]">

  You have {{buildings.length}} buildings. Search:
  <input type="search" ng-model="q" placeholder="filter buildings..." />
  <ul class="example-animate-container">
    <li class="animate-repeat" ng-repeat="building in buildings | filter:q as results">
      [{{$index + 1}}] <strong>Building:</strong>{{building.name}} <strong>Location:</strong> {{building.location}}.
    </li>
    <li class="animate-repeat" ng-if="results.length == 0">
      <strong>No results found...</strong>
    </li>
    <li class="animate-repeat" ng-if="results.length == 555">
      <strong>No results found...</strong>
    </li>
  </ul>
</div>
</body>
</html>

Answer №1

The reason for the issue is related to how you are importing the JavaScript libraries from the CDN:

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.9.3/umd/popper.min.js"></script>

Simply adding https:// should resolve the problem.

Answer №2

The script source you provided does not include a protocol in the URL. Therefore, when opened on your local machine, it is attempting to access file://ajax.googleapis.com..., which does not exist.

To resolve this issue, make sure to include either http or https in the URL when running it on your local machine.

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

What is the best way to deactivate buttons with AngularJS?

I have a situation where I need to disable the save button in one function and permanently disable both the save as draft and save buttons in another function using AngularJS. How can I accomplish this task with the disable functionality in AngularJS? Her ...

Retrieve the number of models from an ajax response that is returning a partial view

I am using ajax to call a method called Issues in the Issues controller. var url = "@(Url.Action("Issues", "Issues"))"; $.ajax({ type: 'POST', url: url, data: issue, dataType: "html", success: function (evt) { $(&apos ...

Setting the date of an input type="date" based on the ng-model value can be accomplished by utilizing the ng-model directive

I need to display a date stored in the $scope variable on an input field type="date" when the page loads. <input class="form-control" type="date" ng-model="asso.formation_of_association" placeholder="" /> However, I am only able to ...

Unordered list in Bootstrap Collapse not responding after initial click

I recently created a filetree page on my website and incorporated some bootstrap collapse elements that seem to function as intended. However, I am encountering an issue where the folder content does not collapse upon clicking the folder symbol (button) fo ...

"Always receive the latest version of the file with every request in Node.js

Essentially, I have developed a server that responds to user requests by sending a JS file in object format. This JS file is generated using two configuration files named config1.js and config2.js. Below is my code snippet: var express = require('ex ...

Loop through an array of elements and dynamically attach event handlers using JavaScript

I'm currently utilizing a loop to generate an array of elements (links) and then connecting them with event handlers (one function for all) before adding them to the DOM. However, I've noticed that the event handler only reacts when I click on th ...

Organizing an angular expansion panel

I am currently dealing with an expansion panel that has a lot of content. The layout is quite messy and chaotic, as seen here: https://ibb.co/Y3z9gdf It doesn't look very appealing, so I'm wondering if there is a way to organize it better or ma ...

Develop a navigation system with forward and backward buttons to easily navigate between

I'm currently delving into angular and striving to implement a next/back button for showcasing various views. Within my repository, I have a template named example.html <h1>{{ message }}</h1> which is utilized by multiple controllers: ...

Issue with JQuery Datepicker default date not functioning properly

I am new to knockout.JS and I'm having trouble setting a default date for my datepicker in the dateoptions. When I try to set it, the default date always shows up as 03/02/2025, which is not what I want. <td><input type="text" class ="mainau ...

What is the method for retrieving a property from an object contained within an array that is assigned to a property of another object?

How can I retrieve the name property from the subjects array within a course object? The database in use is mongodb. Modifying the course model is not an option. The course model : const mongoose = require('mongoose'); const Schema = mongoose. ...

What is the most effective way to extract Geolocation API co-ordinates from my nested function and store them in React state?

My goal is to retrieve a user's location once they click a button using the Geolocation API. <button onClick={this.setNewLatLong()}>"Use my location"</button>; I have successfully obtained the latitude and longitude coordinates with the ...

What steps should I follow to successfully incorporate Zurb Foundation 4 Sections (tabs) into my Javascript Ajax functionality?

I am currently incorporating Zurb Foundation 4.1.5 into my application and I am faced with the challenge of implementing Zurb Section Javascript to handle "tabs" on the page. The content within these tabs is dynamic and fetched via Ajax calls. I am seeking ...

Printing values of an object in an Angular/HTML script is proving to be quite challenging for me

In my Angular project, I have created a service and component for listing objects. The list is functioning correctly as I have tested it with 'console.log()'. However, when I try to display the list on localhost:4200, nothing appears. <table&g ...

When using addClass("test"), it throws an error message: TypeError: undefined is not a function

Upon examination in the console, I discovered the following: $(".myCssClass")[0].parentNode <li><span class="myCssClass">some text</span></li> I am attempting to add a CSS class to the parent span tag within the <li> element ...

How to use jQuery to select an element by using 'this' on a button

I have a total of 5 divs, each containing 5 different texts. <div class="text"> <%= theComment.text %> </div> I am working with node.js, MongoDB, and Mongoose. In addition to the divs, I also have a button labeled EDIT with a cl ...

Ways to turn off .removeClass()

Encountering an issue with jquery-2.1.4.js. Upon integrating a layerslider into my website, the script modified div classes. Attempted using older versions of the script without success. Currently have classes as follows: <a href="#" class="col-md-3 ...

Creating a multi-page form in AngularJS with Tab navigation

Hello, I am currently working on implementing a multi-stage form using AngularJS Tabs. Instead of using routes in this application, I am trying to achieve the desired functionality solely through tabs. app.controller('createProjectController', [ ...

Placeholder text missing in Internet Explorer 11

There seems to be a problem with the placeholder text not showing up in Internet Explorer 11 when using AngularJS. It displays correctly on all other browsers and I have not made any changes to the CSS that could affect it. I even tried disabling all style ...

Struggling with updating an array using React's setState

My issue lies with setState not properly updating my todoItems array. After reviewing similar posts on this forum, I made changes to my addTodoItem() function by utilizing a function and the spread operator. While a new item is successfully added to the ar ...

What is the best method for showing jQuery/Javascript functions in the HTML <pre> element as a string

I am curious about converting jQuery or JavaScript functions to a string and displaying them in an element like <pre> HTML : <pre></pre> jQuery : function test() { alert('test'); } $('pre').html(test()); // &l ...