What steps do I need to follow to get this AngularJs Gallery up and running

As I delve into expanding my knowledge in AngularJS, I've encountered some issues while trying to run code on Plunker.

Could someone take a look at the code and point out what I might be doing incorrectly? The code snippet is provided below:

var app = angular.module('plunker', [])

.controller('AlbumCtrl', function($scope) {
  $scope.images = [
    {category : 'High', image : 'http://lorempixel.com/g/850/400', description : 'Random Photo', stars : '4/5'},
    {category : 'Medium', image : 'http://lorempixel.com/g/850/400/sports', description : 'Sports Photo', stars : '3/5'},
    {category : 'Medium', image : 'http://lorempixel.com/g/850/400/animals', description : 'Animal Photo', stars : '3/5'},
    {category : 'High', image : 'http://lorempixel.com/g/850/400/abstract', description : 'Abstract Photo', stars : '5/5'},
    {category : 'Low', image : 'http://lorempixel.com/g/850/400/business', description : 'Business Photo', stars : '1/5'},
    {category : 'High', image : 'http://lorempixel.com/g/850/400/cats', description : 'Cat Photo', stars : '4/5'},
    {category : 'Medium', image : 'http://lorempixel.com/g/850/400/city', description : 'City Photo', stars : '3/5'},
    {category : 'Low', image : 'http://lorempixel.com/g/850/400/fashion', description : 'Fashion Photo', stars : '2/5'},
    {category : 'High', image : 'http://lorempixel.com/g/850/400/nature', description : 'Nature Photo', stars : '5/5'}
  ];
  
  $scope.currentImage = _.first($scope.images);
  
  $scope.imageCategories = _.uniq(_.pluck($scope.images, 'category'));
    
  $scope.setCurrentImage = function(image) {
    $scope.currentImage = image;
  };
});

http://plnkr.co/edit/6KcKvxHR9mZitFL6eidX?p=preview

I would greatly appreciate any assistance with getting this code up and running. Additionally, once it's functioning properly, I'm looking to enhance it by adding an arrow selector for scrolling through images and changing the main image, as well as implementing a zoom icon for the main image to enable fullscreen viewing. If needed, I'll create a separate query for that.

Your help on this matter would be invaluable.

Answer №1

It appears that you are utilizing underscore js functions without including the necessary library. Once you add the library to your code, it should function properly. Simply insert this line within the head tag.

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>

I've created a fiddle based on your requirements.

http://plnkr.co/edit/OmYPG94kw5lOmDf6X1h4?p=preview

The CSS in the link you shared was originally written using SCSS preprocessor. However, since I wasn't sure if plunkr supports SCSS, I converted it to plain CSS and now everything is functioning correctly.

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

How to minimize the amount of typing needed when specifying grid positions in CSS Grid layout?

(I am currently in the process of upgrading the design of this data entry page from a basic CSS/HTML table layout to something more advanced, utilizing CSS Grid layout). Following common conventions, I have structured it into 12 columns. Each entry field ...

The event SelectedIndexChanged is not triggering as expected on dropdown lists that are created dynamically

My Telerik RadComboBox triggers Javascript on change to fetch data from the database via AJAX and populate a second dropdown list. I need to fill text boxes based on the selection of the second dropdownlist. The code for the two dropdownlists is as follows ...

Spinning in a circular motion to achieve specific degrees and locations

Trying to figure out how to make divs rotate around a circle is proving to be quite the challenge for me. To see what I mean, check out this Fiddle: http://jsfiddle.net/TMuD5/2/ As a junior in JS/JQuery, I've reached my limit of knowledge on this t ...

Spinning and disappearing gradually over a set period of time

Could someone please help me with creating an animation for one of my CSS DIVs? I want it to have an exit/entry effect with rotation/fadeout and then rotation/fadein, with a 10-minute delay between each iteration. I'm not sure if this can be achieved ...

I need to change a website into a string so that I can analyze it with javascript. How can I do this?

Currently, I am in the process of creating a website for my video game servers. The admin tool we use outputs the current server status in a .json format as a large text string to this specific URL: My goal is to retrieve the entire text string from the p ...

How can you store previously calculated values in a costly recursive function in a React application?

Consider a scenario where there is a recursive callback function like the one shown below: const weightedFactorial = useCallback(n => { if (n === 0) { return 1; } return weight * n * weightedFactorial(n - 1); }, [weight]); Is it possible to ...

Preventing users from accessing the previous page via the browser back button after logging out in an AngularJS application

Currently, I have developed an angularjs web application and facing a challenge. After logout, I am looking to prevent users from navigating back to the previous page using the browser's back button. Ideally, I would like to display a customized messa ...

Exploring the capabilities of JSON.stringify in Internet Explorer 11

I encountered a puzzling issue with my JavaScript code – it works flawlessly in Google Chrome 49.0.2623, but causes my entire file to crash in Explorer 11. The problem arises when I attempt to 'Export' JavaScript objects using AJAX. Let me shar ...

Trouble with choosing multiple values in Select2

I'm facing a challenge with my webpage that necessitates the use of the select2 component. The requirement is to display selected values upon loading as well. In my JavaScript file, I have two distinct constructs for this purpose. JavaScript - Constr ...

Personalized Pinterest button to link to a custom URL (Text Link, Image, or Both)

I've been searching for a solution without success. I'm looking to customize the image for my Pinterest (Pin It) button and pin a specific image by URL, not just the current page. Here is the custom link I created: <a href="http://pinterest. ...

Conceal Achievement Notification

The code below signifies a successful update of records. When the user is on the Edit section, they will see the msg just above the update button. I intend for this msg to go away as the user can still make edits to the records. What is the process to hi ...

Tips on customizing the appearance of React rendering components

<div> <h3>{this.props.product.name}</h3> <h3>{this.props.product.code}</h3> {this.renderColors()} <article> <div da ...

The candy stripes on a loading bar zebra assist in creating a unique and

I'm in the process of creating my portfolio and I'd like to incorporate unique animated loading bars, such as vertical or horizontal candy stripes, to showcase my coding skills. Can anyone suggest a specific programming language or tool that woul ...

Issues encountered while trying to implement HTML text within span tags

In my code snippet, I am using a span element: <span> {textToRender} </span> The purpose of this code is to render HTML text (as a string) within a span element. some text <br/> some text <br/> some text <ol>text However, wh ...

Node.js Implementation of HTML Content

Currently, I am attempting to iterate through a list of items and generate HTML code to be passed into the view file: const itemWrap = '<div id="items"></div>'; userDetails.notes.forEach(item => { const itemE ...

Using Angular to bind dynamically inserted HTML div elements

Apologies for the duplication, I have exhausted all similar questions but none provided a solution. I am in the process of integrating angular.js into an existing legacy system. The system currently utilizes the .load jquery function to dynamically load d ...

Getter and Setter Implementation in Typescript without Using Classes

Check out these various SO questions discussing Typescript getters/setters: from 2015, Jan 2018, Sept 2018, and more. Now, the question arises - what is the best approach to define Typescript types for getters/setters in a plain JavaScript object without ...

What is the best way to determine the value of margin-left in inline CSS using jQuery?

Here is the code snippet I am working with: <div class="ongoing" style="width: +728px; margin-left: +12480px"> I need to extract the value of the margin-left property for scrolling purposes. The technique I used to retrieve the width value does no ...

Issue with rendering <li> elements in Firefox browser detected

I have been working on a website and encountered an issue with the display of list elements in Firefox. The list is not showing consistently in Firefox, but it appears fine in IE, Opera, and Safari. I have attached an image below showing the difference bet ...

What is the way to include an additional filter in an AngularJS search filter?

I currently have a functioning search filter in place that utilizes a search input element: <input placeholder="Search" type="text" ng-model="search.$"/> Moreover, I have: <tr ng-repeat="person in people | filter:search:strict"> <td> ...