简体   繁体   中英

Error while using angular JS directives

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>

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.

您无需在ng-repeat中传递{{}}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM