通过该指令的属性将数组传递给指令时,我目前遇到问题。我可以将其读取为字符串,但我需要将其作为数组,所以这是我想出的,但它不起作用。帮助任何人?提前谢谢
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']" ... >