Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to call multiple objects from my JSON file for various different sections on my site. As it stands i have the jobs and a misc section for section titles etc. With my HTML i have the following

<h2>{{job.jobTitle}}</h2>

This works fine. However the misc section doesn't display any content

<h1>{{title.widgetTitle}}</h1>

plunkr

"jobs": [
    {
        "jobTitle": "Senior Accountant",
        "sector": "Accounting & Finance",
        "link": "/jobs/1"
    },
 ],
 "title": [
            {"widgetTitle": "Latest Jobs"}

         ]

HTML

 <div class="tickr-container" data-ng-controller="tickCtrl">
            <div>   
                <h1>{{title[0].widgetTitle}}</h1>
            </div>

            <div>
                <h3>{{date | date:'fullDate' : 'GMT'}}</h3>

                <ul ng-mouseover="stopAuto()" ng-mouseleave="startAuto()" class="tickrSlider">
                    <li class="tickrSlider-slide" ng-class="{'job-active' :isActive($index)}" data-ng-repeat="job in jobs">
                        <div class="tickrSlider-inner">
                            <h2>{{job.jobTitle}}</h2>
                            <p>{{job.sector}}</p>
                            <a class="tickrSlide-info" href="{{job.link}}">{{job.link}}</a>
                        </div>
                    </li>
                </ul>
share|improve this question
    
Your json in plunkr is missing the "misc" section. You have invalid html there as well. Unclosed a, div, nav tags. –  Henri Hietala Mar 14 at 14:23
    
@HenriHietala that's that's a typo from copying and pasting my code. The misc section is "title" –  NewKidOnTheBlock Mar 14 at 14:34
    
It's because widgetTitle is inside an array. Try: {{title[0].widgetTitle}} –  Pataar Mar 14 at 14:38

1 Answer 1

Shouldn't you reference title[0].widgetTitle?

<h2>{{job.jobTitle}}</h2> appears fine since you reference the job object from data-ng-repeat="job in jobs"

share|improve this answer
    
i am assume in order to display objects within the title array in will be title in titles etc ? –  NewKidOnTheBlock Mar 14 at 14:51
    
Yep, just like you did with 'jobs' –  Tom Teman Mar 14 at 14:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.