Arn*_*der 11 angularjs angularjs-ng-repeat
我想知道是否可以执行以下操作:
<div ng-repeat='article in articles | filter:search'>
...
<div>
{{marked(article.body)}}
</div>
...
</div>
Run Code Online (Sandbox Code Playgroud)
所以我想执行"标记"功能,将文章正文作为参数传递并显示生成的输出.
gia*_*pot 11
当然,语法没问题!:)
您所需要的只是使marked功能在正确的范围内定义.例如,假设您在ArticleCtrl控制器中:
app.controller('ArticleCtrl', function($scope) {
// Declare the method in the controller's scope
$scope.marked = function(article_body) {
// do whatever you want here
// and don't forget to return the expected result
return "LOVE CAPS! " + article_body.toUpperCase();
};
});
Run Code Online (Sandbox Code Playgroud)
然后{{ marked(something) }},您可以在模板中使用.
| 归档时间: |
|
| 查看次数: |
17019 次 |
| 最近记录: |