【发布时间】:2013-04-23 20:03:16
【问题描述】:
我目前在通过该指令的属性将数组传递给指令时遇到问题。我可以将其读取为字符串,但我需要将其作为数组,所以这就是我想出的,但它不起作用。帮助任何人?提前考虑
Javascript::
app.directive('post', function($parse){
return {
restrict: "E",
scope:{
title: "@",
author: "@",
content: "@",
cover: "@",
date: "@"
},
templateUrl: 'components/postComponent.html',
link: function(scope, element, attrs){
scope.tags = $parse(attrs.tags)
}
}
}
HTML::
<post title="sample title" tags="['HTML5', 'AngularJS', 'Javascript']" ... >
【问题讨论】:
标签: arrays parsing angularjs attributes directive