javascript - "Error: Syntax Error unexpected token" in custom Angular Directive attributes -
i'm testing out angular & trying build custom angular directive, i'm running weird console errors.
my directive defined as:
.directive('iprecentactivityitem', function() { return { restrict: 'a', replace: true, transclude: true, scope: { 'title': '@title', 'icon': '@icon', 'timeago': '@timeago', 'meta': '@meta', }, templateurl: ip_path + '/app/components/recent-activity/recent-activity-item.tpl.html' } });
my template is:
<div class="recent-activity-item"> <div class="recent-activity-content"> <div class="recent-activity-message"> <a href="" class="recent-activity-title"> {{title}} </a> <div class="recent-activity-meta"> {{meta}} </div> <div data-ng-transclude></div> </div> </div> <a href="" class="recent-activity-timeago">{{timeago}}</a> </div>
then, in view, i'm trying call with:
<div data-ip-recent-activity-item title="my item title" icon="my item icon" timeago="4 hours ago" meta="someone commented on issue in garageband"> item content </div>
in rendered page, showing should, console throwing these types of errors: error: syntax error: token 'item' unexpected token @ column 4 of expression [my item title] starting @ [item title].
if rid of spaces, error goes away, don't understand why is. can enlighten me? thanks! i'm still new angular arena, kind! :)
edit: forgot mention i'm running angular version 1.1.5
i'm pretty sure because angular tries evaluate bits in quotes. try adding single quotes , see if message goes away
<div data-ip-recent-activity-item title="'my item title'" icon="'my item icon'" timeago="'4 hours ago'" meta="'someone commented on issue in garageband'"> item content </div>
Comments
Post a Comment