Error: ngRepeat:dupes Duplicate Key in Repeater - asp.net

I have a column(I call it in my codebehind as keyW) in a stored procedure that returns this value
[{key:138},{key:139},{key:140},{key:141},{key:142},{key:143},{key:145},{key:146},{key:148}]
on my design view I have put the code like this
<div id="allerg" ng-repeat="allerg in recipe.keyW">
{{allerg.key}}
</div>
When I run my page it returns the duplicate key error. I am not sure what is wrong. I am returning the right values as what I have read in the ng-repeat documentation
thank you in advance
EDIT: I have also tried the track by $index. It removes the error but still doesn't display the values.

Try changing your div ID to something other than allerg

If your array contains int add "track by $index" to your code.
<div id="allerg" ng-repeat="allerg in recipe.keyW track by $index">
{{allerg.key}}
</div>

Related

How to Fix 'Each child should have a unique key prop?

Hi everyone I would like to display for each element all of its sub-documents.
<div><ul>{designModdulles.map((designModdulle)=><li key={designModdulle.epreuves.nature_epreuve}>{designModdulle.epreuves.nature_epreuve}</li>) }</ul></div>
```
I wanted the sub documents to be displayed` in a map
but i had: Warning: Each child in a list should have a unique "key" prop.
Assuming this is JavaScript, the cause of the issue is that there are duplicate key values. You can use the index of each map entry to create a new key
<div><ul>{designModdulles.map((designModdulle, index)=><li key={designModdulle.epreuves.nature_epreuve + index}>{designModdulle.epreuves.nature_epreuve}</li>) }</ul></div>
You may want to look at the following to see what your choices are (there are other resources as well): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
the problem of the key is resolved, but nothing is displayed in the tag
hello everyone here is the solution:
<ul><li>{designModdulles.map((item,index)=>(<div key={index}>{item.epreuves.map((c, i)=>(<div key={i}>
<h3>{c.code_epreuve}</h3><Button>Insérer notes</Button><Button>Supprimer</Button> </div>) )}</div>))}</li></ul>
thank you

How can I find classname an element with multiple classes in cypress

I'm a tester, and I have this HTML code.
<div id="columns">
<div class="column ce-editable c1">
</div>
</div>
I'm using Cypress. I want to examine if there is 'c1' class name found in the div element. If I try:
cy.xpath ('//div[#id="columns"]//div')
.should('have.class', 'c1')
I have this error:
CypressError: Timed out retrying: You attempted to make a chai-jQuery assertion on an object that is neither a DOM object or a jQuery object.
The chai-jQuery assertion you used was:
> class
The invalid subject you asserted on was:
> [<div.column.ce-editable.c1>]
To use chai-jQuery assertions your subject must be valid.
This can sometimes happen if a previous assertion changed the subject.
May I give you a whole other direction. It goes far, far away from using Xpaths :). What you can do to archive what you want is the following:
cy.get('#columns')
.find('div')
.should('have.class','c1')
This results in a few positive things:
1. It's easier to read what is happening
2. Debugging is easier, you'll see that Cypress tries to verify c1 in three steps. First find some ID with 'columns', than find a div below that and finish with asserting that the last searched div has a class called 'c1'.
3. The results show more neath since should() is actual an assertion instead of an action.

Accessing one element in an array using Firebase-collection in polymer

I am trying to use the new firebase-collection introduced in Polymer 1.0 to access one element in an array in my firebase nosql database. However, I get back nothing.
Here's a snippet of my code:
<firebase-collection data="{{testItem}}"
location="https://<firebase-path>.firebaseio.com/testItems/0/">
</firebase-collection>
<section class="layout vertical center-center" id="moreInfo">
<div class="layout vertical">
<test-block art="{{testItem}}"></test-block>
</div>
</section>
Notice how I am trying to access item at index 0 in https:///firebaseio.com/testItems. Is it even possible to access it using firebase-collection? Or should we just fetch the collection and then iterate?
Yeah that approach won't work since the data property expects/is populated with an array of data from your DB. I believe if you set the location to "https://.firebaseio.com/testItems" that you can reference the first item in the data array like so:
<test-block art="{{testItem.0}}"></test-block>
Another approach if you know the Firebase key of the item you want would be to use firebase-collection's getByKey method in your Javascript.

MinValue for dx:ASPxSpinEdit doesn't works (asp.NET VB)

I try to create a form in which I added a dx:ASP:SpinEdit, which is a control able to control numeric data. I use it because I want the user only to put numeric value.
Here is the code I used to create it (graphically, not programmatically way) :
<form id="f_main" runat="server">
<dx:ASPxSpinEdit ID="se_quantity" MinValue="1" runat="server"></dx:ASPxSpinEdit>
</form>
I would this element to block user from changing the value if it goes down 1. I am doing wrong with it ? Or should I use another control (I would in the best case keep this control).
In fact I didn't mentionned the type of my element, and the maxValue. I found a trick to overpass the fact that we should necessary put a MaxValue with a MinValue, and not only a MinValue. Here is how I did :
<dx:ASPxSpinEdit ID="spinEdit_1" MinValue="1" MaxValue="79228162514264337593543950335" NumberType="Integer" runat="server"></dx:ASPxSpinEdit>
The reason why I put a such long integer is that I needed the user to put a number from 1 to infinite (theorically). I searched for "Max value for MaxValue parameter for SpinEdit DevExpress" and I found this number by typing in my C# filethe following code :
Console.Write(spinEdit_1.MaxValue);
Then I found this number and put it in the "MaxValue" parameter. I should also precise the "NumberType" paramter for the user not to enter commas.
Hope it helps for similars problems.

Undefined Method in HTTParty class

I'm somewhat new to rails and every time I think I'm getting it I hit a wall.
I'm using HTTParty and this API. I am just trying to get a response to show up in my index view to get the lowest level of the api working.
It worked for me in the console but not when I tested it in the API. I'm getting an
undefined method `picture' for Snapshots:Class
error for my index view.
Here is the HTTParty class
class Snapshots
include HTTParty
def initialize
#sitename = "google.com"
end
def picture
response = HTTParty.get("http://api.snapito.com/web/516e011353b62078731712566b01e143f56adf0b/full/diditmatter.herokuapp.com/lists")
if respone.success?
response
end
end
end
Here is my lists controller
def index
#it_works = Snapshots.picture
respond_with(#lists = List.all)
end
And here is list view
<%= #it_works %>
<h1 class="page-header">Projects at a glance</h1>
<div class="span12 offset2">
<% #lists.each do |list| %>
<div class="well row span4">
<div class="span3">
</div>
<div class="span4">
What do I seem to be overlooking here?
EDIT
#Benjamin fix worked, but I've come across a problem I'm not sure is related to rails. I'm not sure is I should open another question. But since the context is here and I'm not really even sure how to search this, I have to follow up here.
That instance variable is returning the attached screen shot. Is this related to how I'm calling it from the API I linked to in the first paragraph?
I've never seen this so not to sure where to look or how to approach.
You are treating the picture method as a class method. Change it to this: #it_works = Snapshots.new.picture

Resources