Reputation: 2693
I am new to angular JS and trying to use Directives.
Below is the code for directive :
app.directive('appInfo', function() {
return {
restrict: 'E',
scope: {
info: '='
},
templateUrl: 'js/directives/appInfo.html'
};
});
Below is my main JS:
app.controller('MainController', ['$scope', function($scope) {
$scope.apps = [
{
icon: 'img/move.jpg',
title: 'MOVE',
developer: 'MOVE, Inc.',
price: 0.99,
info: "move"
}
]
}]);
Now, when i am trying to use this in html i am getting very bad error that ia ma unable to under stand :
<div class="card" ng-repeat = "app in apps">
<app-info info="{{ app.info }}"></app-info>
</div>
Upvotes: 0
Views: 55
Reputation: 3717
You don't need to pass {{}}
in ng-repeat.
<app-info info="app.info"></app-info>
Upvotes: 1
Reputation: 5469
While passing data to angular directive, you don't need to use interpolation, pass the data directly like this:
<div class="card" ng-repeat = "app in apps">
<app-info info="app.info"></app-info>
</div>
Hope it helps.
Upvotes: 1