Issues with registering double brackets in Angular.js HTML are causing some problems

After delving into angular.js recently (and I use the term "delve" loosely), I have been working on creating a basic website and hit a roadblock with form validation. It seems that the double bracket notation I picked up from "Shaping up with angular.js" is not functioning properly on my current webpage. I've been tinkering with this all day and there are likely several issues in my code (feel free to provide feedback).

The specific code snippet causing the trouble is as follows:

<div class="divvy" ng-repeat="slider in main.sliders">
  <h3>
    {{slider.name}} costs {{slider.cost | currency}}
  </h3>
</div>

I can share the entire code, but for context, the class "divvy" is just a roundabout way to center the div on the screen. The header section looks like this:

<head>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <link href="https://fonts.googleapis.com/css?family=Didact+Gothic|Ek+Mukta|Montserrat" rel="stylesheet">
    <script type="text/javascript" src="script.js"></script>
    <script type="text/javascript" src="//code.angularjs.org/snapshot/angular.min.js"></script>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

  </head>

Regarding the script.js file, it's quite simple since I haven't made any significant changes to it yet other than debugging the issue at hand.

(function(){
var app = angular.module("myModule",[]);
app.controller('MainController',function(){
  this.products= sliders;
});


var sliders= [

  {name:  "Charles",
    cost:  "4.20"
  },
  {
    name:"Alfred",
    cost:"30"
  },
  {
    name:"Something that costs 10 bucks",
    cost:"10.1"
  }



  ]

  })()

I would greatly appreciate some assistance. I suspect that another attempt to fix something might have interfered with proper angular use (there's a button intended for text editing within the code, which used to function but stopped after accidentally undoing some changes). Furthermore, if you have the time, there's a background image that I spent considerable effort centering and ensuring it's "zoom-proof," but now I want to dynamically change it (background shifts with slides or fade transitions) and the background image is specified in style.css html{}... And I'm unsure how to alter that using "myStyle" or even incorporate ng-myStyle. Thank you. The complete code is available at plunker, here: https://plnkr.co/edit/H4uhcU

Answer №1

It should appear as follows:

<div class="divvy" ng-repeat="slider in main.products">

DEMO

var app = angular.module("myApp",[]);
app.controller('MainCtrl',function(){
  var sliders= [
  {name:  "John",
    cost:  "5.50"
  },
  {
    name:"Bob",
    cost:"20"
  },
  {
    name:"Item that costs 15 bucks",
    cost:"15.9"
  }];

  this.products= sliders;
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app= "myApp" ng-controller="MainCtrl as main">
<div class="divvy" ng-repeat="slider in main.products">
  <h3>
    {{slider.name}} is priced at {{slider.cost | currency}}
  </h3>
</div>
 

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

Toggling with Jquery when an image is clicked

I'm trying to wrap my head around the functionality of jquery toggle. My goal is to toggle to the next anchor element with the class plr-anchor when an image with the class go_down is clicked. The information is being populated using maps. Javascript ...

What are the best practices for preloading images, JavaScript, and CSS files?

Back in the late 90's, I was really passionate about creating websites from scratch. However, as I dove back into web development recently, I realized how much the landscape has changed since then. As more of a designer than a developer, I opted to us ...

Attempting to assign a new class to a <div> using JavaScript

I'm facing an issue where I need to add a class to a div without replacing the existing classes. Despite my code being correct, it doesn't seem to work as expected. function clickTab(clicked_id) { var x = clicked_id x.className += " active ...

Unexpected behavior with async pipe - variable becomes undefined upon reassignment

In my development process, I have implemented 2 components. One is responsible for fetching data from an external service, while the other one displays this data. The constructor of the first component is structured as follows: constructor( private dev ...

Is it possible to dynamically change the color of a box shadow using an event handler?

I'm currently in the process of developing an application that consists of six distinct topics organized within a flexbox structure, complete with a box-shadow effect. My objective is to dynamically alter the color of the box-shadow through an event ...

Physically moving the window to a specified location using window.scrollTo()

Whenever I use the window.scrollTo(); method upon clicking a button, it simply jumps to the destination without displaying the scrolling motion. How can I ensure that the window physically scrolls to the designated position instead of instantly appearing ...

angularjs bootstrap typeahead result offspring

I have a situation where my input is bound to the object line.product, but the typeahead function is returning pairs of products and suppliers. The current code ps.product as ps.product.code for ps in getProductSupplierRefList($viewValue) does not return t ...

Using CSS: Leveraging the power of CSS selectors for styling child elements

I attempted to implement a CSS style that targets a child element of the body based on the active state of another div class. Here is the HTML structure: <body class="restrict-body-scroll"> <div class="main-wrapper"> <div class ...

JavaScript code to enforce a 100% page zoom setting

After developing a small game in Canvas, I encountered an issue. Some users with their default zoom level set to something other than 100% are unable to view the entire game page. I attempted to resolve this by using the following CSS: zoom: 100%; This ...

What is the best way to vertically center my text on the right and left sides of an image?

I am struggling to align the text on the left and right side of my image to the vertical center. It seems like my containers are not recognizing their height. How can I resolve this issue? Here are the CSS and HTML snippets for your reference: .footer { ...

Is it possible to track keystrokes without the use of text input fields?

For various unimportant reasons, I need to use JavaScript to create links instead of using the anchor tag. I want the behavior to mimic the anchor tag, allowing users to open a link in a new tab when holding down the Ctrl key or in a new window when holdin ...

Does Angular's $pristine functionality work effectively with nested input fields in forms?

My form is causing me some problems. Two main issues I'm encountering: 1 - When trying to check for $pristine on the form using console.log($scope.myFirstForm.$pristine);, I keep getting the error message: `cannot read property '$prestine' ...

The art of defining, arranging, and organizing AngularJS functions, their placement

Just diving into AngularJS and I've discovered two different ways to declare functions: The first way: var myApp = angular.module('myApp', []); myApp.controller('mainCtrl', function($scope){ $scope.message = 'Yes'; ...

Guidelines on centering an AJAX spinning animation within a parent div

Below is the basic structure of an HTML document for a webpage. <div class="grand-parent"> <div class="header">Heading</div> <div class="parent-div"> <div class="child-div-1"></div> ...

CSS elements unexpectedly remain in line

I have encountered an issue with a navigation bar on one of my website projects. The HTML elements I am trying to add afterwards are not aligning properly with the navbar. I have thoroughly checked for any open HTML tags, syntax errors, or conflicting CSS ...

jQuery toggle functioning in one scenario, but failing in another

My experience with JS/Jquery is limited which might explain why I'm struggling with this. I am attempting to hide some text on a page and then make it visible again by clicking on a toggle link. The JavaScript code below is what I have been using. The ...

Traversing through nested arrays within nested objects using AngularJS

In my project, I am utilizing angularjs 1 and dealing with a complex json object that has multiple levels of nesting. My goal is to use ng-repeat in order to access a nested array within the json structure. [{ "information": { "name": "simdi jinki ...

Solving Problems with D3.js Mouseover and Focus + Context

I am just starting to explore the world of D3.js, I've completed a few tutorials and dived straight into my initial project. My intention was to combine the concepts from the following examples with some modifications to suit my specific requirements. ...

What would cause this to result in a blank array?

I have a main component that contains multiple sub-components, which I navigate between by clicking on different elements. These sub-components are all Vue files. What I am trying to achieve is to dynamically highlight the active component when it is bein ...

The webpage does not dynamically resize based on screen height

Encountered an issue with the excess space below the footer. Resolved it by implementing a jQuery sticky footer as CSS techniques were unsuccessful. However, facing a problem with the main content of the webpage. Adjustment of .bg-photo's height impa ...