Please Help, I just started to read angularJS
I have a ojects with keys like
scope.eventList=[];
for(){
var event = {
id : hash,
title : title,
url : 'http://www.xxxxx.com/',
start : start,
end : end,
allDay : false,
location : '',
description : '',
editable : true
};
$scope.eventList.push(event);
}
which gives an eventList (array of objects):
[
{
id : hash,
title : "TITLE1" ,
url : 'https://www.xxxxx.com/',
start : start,
end : end,
allDay : false,
location : '',
description : '',
editable : true
},
{
id : hash,
title : "TITLE2" ,
url : 'https://www.xxxxx.com/',
start : start,
end : end,
allDay : false,
location : '',
description : '',
editable : true
}
]
I need to put this into an ng-repeat but only show the item's titles
like : Title1
Title2
Title3
......
TitleN
Tried the following but it doesn't work.
<div customEventName="{{item.title}}"
ng-model="item" ng-repeat="item.title in eventList track by $index">
{{item.title}}
</div>
Many thanks for help.
You don't need ng-model
neither track by $index
in your case.
Your issue is that the Y
of the Y in X
inside ng-repeat
is the "target" variable that will contain the current item contained in the array X
.
The correct code is then:
<div
ng-repeat="item in eventList"
customEventName="{{item.title}}">
{{item.title}}
</div>