使用角度 JS 指令时出错
Error while using angular JS directives
我是角度JS的新手,并尝试使用指令。
以下是指令的代码:
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 中使用它时,我遇到了非常严重的错误,ia ma 无法忍受:
<div class="card" ng-repeat = "app in apps">
<app-info info="{{ app.info }}"></app-info>
</div>
在将数据传递给角度指令时,不需要使用插值,直接像这样传递数据:
<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>
相关文章:
- 在指令控制器中使用$attrs时出现问题
- 参数变量出现ngTable指令问题
- javascript中的数组出错
- 节点Js:How to catch a“;没有这样的文件或目录“;读取线模块出错
- 在AngularJS应用程序中使用封装指令和路由的推荐方式是什么
- 使用每次都不同的transclude重复指令
- 打开一个模态并将其链接到AngularJS中的指令
- 从html创建一个指令,该指令按类名应用函数
- 将JSON对象传递给angular指令
- 如何使用ngrepeat和双向绑定获得指令的隔离范围
- JavaScript指令不能像我想象的那样工作
- AngularJs指令,该指令创建内部有数据对象的新指令
- AngularJS指令只识别双向绑定类型
- 在Meteor项目中安装并包含npm模块后出错
- AngularJS指令出错-无法读取属性'编译'的未定义
- 使用 ng-repeat呈现嵌套指令时出错
- 使用角度 JS 指令时出错
- 更新链接函数中的指令范围时出错
- 打开模态时angular js指令出错
- AngularJS在指令中包装jQuery插件时出错