user944513
user944513

Reputation: 12729

why ng-repeat not work in directive using angular?

I am trying to use directive in mu page ..I am trying to send data from controller to directive .I am trying to display data using ng-repeat.

here is I am applying the ng-repeat .

  <div class="container">
            <!--Row with two equal columns-->
            <div class="row " ng-repeat='d in data'>
                <div class="col-sm-3">
                    <div class="demo-content">{{d.Location}}</div>
                </div>
                <div class="col-md-7">
                    <div class="demo-content bg-alt description-ellipse">{{d.description}}</div>
                </div>
                <div class="col-md-1">
                    <div class="demo-content bg-alt">
                        <button type="button" class="btn btn-default view-now-button">VIEW NOW</button>
                    </div>
                </div>
            </div>
        </div>

I make a directive like this

.directive('listComponent', function() {

        return {
            restrict: 'E',
            scope: {
              data:'='
            },
            templateUrl: 'list.html',
            link: function(s, e, a) {

            }
        }

    })

I am sending data like that

data:'=' and from here <list-component data='h.data'></list-component>

here is my code http://plnkr.co/edit/Q0GQC2Pik7m25HxQIW8H?p=preview

Upvotes: 2

Views: 432

Answers (1)

michelem
michelem

Reputation: 14590

It should be:

<div class="row " ng-repeat='d in data.jobs'>

in list.html

Or, as per comment:

<list-component data='h.data.jobs'></list-component>

Updated Plunker

Upvotes: 2

Related Questions