繁体   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