0

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>
3
  • What is the error you cannot understand? Commented Feb 23, 2016 at 10:52
  • getting very bad error that ia ma unable to under stand ........... what error? Commented Feb 23, 2016 at 10:56
  • Error: [$parse:syntax] http://errors.angularjs.org/1.3.5/$parse/syntax?p0=%7B&p1=invalid%20key&p2=2&p3=%7B%7B%20app.info%20%7D%7D&p4=%7B%20app.info%20%7D%7D Commented Feb 24, 2016 at 5:28

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

This resolved the error but i am not able to see the app-info directive UI that is present in html file linked.
1

You don't need to pass {{}} in ng-repeat.

 <app-info info="app.info"></app-info>

1 Comment

This resolved the error but i am not able to see the app-info directive UI that is present in html file linked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.