簡體   English   中英

使用角度JS指令時發生錯誤

[英]Error while using angular JS directives

我是有角JS的新手,正在嘗試使用Directives。

以下是指令的代碼:

app.directive('appInfo', function() { 
  return { 
    restrict: 'E', 
    scope: { 
      info: '=' 
    }, 
    templateUrl: 'js/directives/appInfo.html' 
  }; 
});

以下是我的主要JS:

app.controller('MainController', ['$scope', function($scope) {
    $scope.apps = [
      {
        icon: 'img/move.jpg',
        title: 'MOVE',
        developer: 'MOVE, Inc.',
        price: 0.99,
        info: "move"
      }
    ]
}]);

現在,當我嘗試在html中使用它時,我收到了非常糟糕的錯誤,我可能無法理解:

<div class="card" ng-repeat = "app in apps">
    <app-info info="{{ app.info }}"></app-info>
 </div>

在將數據傳遞到angular指令時,您無需使用插值,直接將數據傳遞如下:

<div class="card" ng-repeat = "app in apps">
  <app-info info="app.info"></app-info>
</div>

希望能幫助到你。

您無需在ng-repeat中傳遞{{}}

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM